You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in the following piece of code, if we add 'print(f"clf.feature_names_in:{clf.feature_names_in_}")' after the fit() function is called,
it will pop up an issue that 'AttributeError: 'Ridge' object has no attribute 'feature_names_in_''
# Train the model with different regularisation strengthsforainalphas:
clf.set_params(alpha=a)
clf.fit(X, y)
print(f"clf.feature_names_in:{clf.feature_names_in_}")
coefs.append(clf.coef_)
errors.append(mean_squared_error(clf.coef_, w))
As documented in the attributes section of the Ridge documentation (and this rule apply to all estimator), feature_names_in_ is only available if the X as all string columns:
Describe the bug
the issue appears in the example of https://scikit-learn.org/stable/auto_examples/linear_model/plot_ridge_coeffs.html#sphx-glr-auto-examples-linear-model-plot-ridge-coeffs-py
in the following piece of code, if we add 'print(f"clf.feature_names_in:{clf.feature_names_in_}")' after the fit() function is called,
it will pop up an issue that 'AttributeError: 'Ridge' object has no attribute 'feature_names_in_''
sklearn version is 1.01
Steps/Code to Reproduce
Expected Results
it is expected to print the attribute of feature_names_in_
Actual Results
but it raised an error.
AttributeError: 'Ridge' object has no attribute 'feature_names_in_'
Versions
System:
python: 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)]
executable: C:\Users\ezqiuya\AppData\Local\Programs\Python\Python38\python.exe
machine: Windows-10-10.0.18362-SP0
Python dependencies:
pip: 21.3.1
setuptools: 59.1.1
sklearn: 1.0.1
numpy: 1.21.4
scipy: 1.7.2
Cython: 0.29.24
pandas: 1.3.4
matplotlib: 3.5.0
joblib: 1.1.0
threadpoolctl: 3.0.0
Built with OpenMP: True
The text was updated successfully, but these errors were encountered: