sassoftware / sas-viya-dmml-pipelines

Code examples and supporting materials for data mining and machine learning techniques on the SAS Viya environment.
Apache License 2.0
30 stars 26 forks source link

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

Closed smlindauer closed 6 months ago

smlindauer commented 6 months ago

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 commented 6 months ago

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