Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Source Code Node Example - Deprecated scikit-learn functionality #12

Closed
smlindauer opened this issue Apr 22, 2024 · 1 comment
Closed

Comments

@smlindauer
Copy link

In the hmeq_train.py code for the registery_py_model example, some users will find that the current Python code utilizes a scikit-learn method that has been deprecated. Specifically on line 66, the get_feature_names() method was deprecated in version 1.2 of scikit-learn.

I believe a simple solution for the code would be a try/except block as follows:

try:
    full_input_vars = dm_interval_input + list(class_ohe.get_feature_names())
except AttributeError:
    full_input_vars = dm_interval_input + list(class_ohe.get_feature_names_out())

Or to explicitly validate the scikit-learn version:

import sklearn
from distutils.version import StrictVersion
if sklearn.__version__ >= StrictVersion("1.2.0"):
    full_input_vars = dm_interval_input + list(class_ohe.get_feature_names_out())
else:
    full_input_vars = dm_interval_input + list(class_ohe.get_feature_names())
@rmyneni
Copy link
Contributor

rmyneni commented May 3, 2024

Thanks so much for the feedback @smlindauer - pushed your suggestion with try/except block to master.

@rmyneni rmyneni closed this as completed May 3, 2024
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

No branches or pull requests

2 participants