Skip to content

Pass two-dimensional endpoints to plot_linear_regression estimators - #1253

Open
ktz03 wants to merge 1 commit into
rasbt:masterfrom
ktz03:fix/linear-regression-endpoints-0334
Open

ktz03 wants to merge 1 commit into
rasbt:masterfrom
ktz03:fix/linear-regression-endpoints-0334

Conversation

@ktz03

@ktz03 ktz03 commented Oct 15, 2026

Copy link
Copy Markdown

Code of Conduct

Reviewed the repository's Code of Conduct.

Description

plot_linear_regression fits an estimator using a two-dimensional feature array, but passes scalar endpoints to predict. The default scikit-learn LinearRegression therefore rejects even the existing User Guide example with Expected 2D array, got scalar array instead.

Pass each endpoint as a single-feature sample and extract its prediction. Keep the fitted coefficients, correlation, line limits and plotting options unchanged. Add regressions for the documented data, list/array/column inputs, explicit and automatic limits, LinearRegression/Ridge, and custom correlation/legend options.

Related issues or pull requests

Fixes #1252

Pull Request Checklist

  • Added a note to ./docs/sources/CHANGELOG.md.
  • Added regression tests in ./mlxtend/plotting/tests/test_plot_linear_regression.py.
  • Modified the corresponding User Guide notebook: not applicable; its existing example is restored without an API change.
  • Ran the focused test file with branch coverage: 14 passed. The same final tests on the unmodified implementation report 14 failed. This is the focused verification allowed for small changes by the template; the full repository suite was not run.
  • Checked style: changed-file Black and isort passed. Repository-wide flake8 reports the same pre-existing W293 in frequent_patterns/tests/test_association_rules.py:62 on baseline and fixed code.

The broader plotting test directory cannot collect on either baseline or fixed code because its existing test_pca_corr_graph.py compares a Version object with a string. No test or CI threshold was changed.

Validated locally on Windows, Python 3.12.14, NumPy 2.4.0, SciPy 1.16.3, scikit-learn 1.8.0 and Matplotlib 3.10.8 (Agg backend). No other platform, interactive display or upstream CI pass is claimed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plot_linear_regression passes scalar endpoints to scikit-learn predict

1 participant