ResidualsPlot: "UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names"
See original GitHub issueDescribe 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:
- Created a year ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
I just updated to v1.5 and the issue is indeed fixed. Thanks a lot!
@luukburger we just released Yellowbrick v1.5 – please update to the latest version and this fix should be addressed!