question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ResidualsPlot: "UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names"

See original GitHub issue

Describe the bug I’m running a ResidualsPlot on an LinearRegression Estimator that is already fitted using sklearn. The Estimator was fitted using an X_train DataFrame including column names, and a y_train Series which is also named.

Now when I draw a ResidualsPlot on the fitted model using yellowbrick, I get an sklearn warning in my notebook:

~/opt/miniconda3/envs/py39ds/lib/python3.9/site-packages/sklearn/base.py:450: UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names

The warning is not thrown when I fit using yellowbrick, but I’d rather use yellowbrick only for drawing the ResidualsPlot and not change the rest of my notebook.

To Reproduce Warning thrown with this code:

lin_reg = LinearRegression()
lin_reg.fit(X_train_scaled, y_train)

fig, ax = plt.subplots(figsize=(15, 10))
_ = residuals_plot(estimator=lin_reg,
                   is_fitted=True,
                   ax=ax,
                   X_train=X_train_scaled,
                   y_train=y_train,
                   X_test=X_test_scaled,
                   y_test=y_test)

Warning not thrown with this code:

fig, ax = plt.subplots(figsize=(15, 10))
_ = residuals_plot(LinearRegression(), ax=ax, X_train=X_train_scaled, y_train=y_train, X_test=X_test_scaled, y_test=y_test)

Expected behavior The warning says “X does not have valid feature names” but it does, so I don’t understand why it’s thrown.

Desktop

  • OS: macOS 12.4
  • IDE: VS Code 1.68.1 + Jupyter Extension v2022.5.1001601848 + miniconda 4.13
  • Python 3.9.12 + yellowbrick 1.4

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
luukburgercommented, Aug 30, 2022

I just updated to v1.5 and the issue is indeed fixed. Thanks a lot!

0reactions
bbengfortcommented, Aug 21, 2022

@luukburger we just released Yellowbrick v1.5 – please update to the latest version and this fix should be addressed!

Read more comments on GitHub >

github_iconTop Results From Across the Web

UserWarning: X does not have valid feature names, but ...
UserWarning : X does not have valid feature names, but LinearRegression was fitted with feature names warnings.warn( · Ask Question. Asked 1 ...
Read more >
UserWarning: X does not have valid feature names,? - Part ...
I am getting several UserWarning errors when using 09_tabular code. ... 09_tabular code: UserWarning: X does not have valid feature names,?
Read more >
Crude Oil Price Prediction: Linear Regression
/kaggle/input/crudeoil/Linear Regression Data.xlsx ... UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names ...
Read more >
Ml regression in Python
We will be using the Linear Regression, which is a simple model that fit an ... UserWarning: X does not have valid feature...
Read more >
Residuals Plot — Yellowbrick v1.5 documentation
If the points are randomly dispersed around the horizontal axis, a linear regression model is usually appropriate for the data; otherwise, a non-linear...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found