Cauchemare / Light_FAMD

Light version Factor analysis for Mixed Data
BSD 2-Clause "Simplified" License
13 stars 5 forks source link

AttributeError: 'OneHotEncoder' object has no attribute 'get_feature_names' #7

Open TaurusLegend opened 1 year ago

TaurusLegend commented 1 year ago

Describe the bug While fitting the model FAMD using the given data, the program ends with an error message. The class OneHotEncoder class does not have the method get_feature_names. This method was deprecated in the scikit-learn version 1.0 and renamed to get_feature_names_out in the version 1.2.

To Reproduce Steps to reproduce the behaviour:

  1. Instantiate an object of FAMD class
  2. Call the method fit by giving the training data
  3. Run the python script
  4. Observe the error message

Expected behaviour It was expected to fit the model using the given data successfully.

Screenshots

famd = FAMD(n_components=X.shape[1], n_iter=3)
famd.fit(X)
/home/quadmin/.local/lib/python3.8/site-packages/sklearn/preprocessing/_encoders.py:868: FutureWarning: `sparse` was renamed to `sparse_output` in version 1.2 and will be removed in 1.4. `sparse_output` is ignored unless you leave `sparse` to its default value.
  warnings.warn(
Traceback (most recent call last):
  File "famd-light.py", line 40, in <module>
    famd.fit(X)
  File "/home/quadmin/.local/lib/python3.8/site-packages/light_famd/famd.py", line 45, in fit
    return super().fit(X)
  File "/home/quadmin/.local/lib/python3.8/site-packages/light_famd/mfa.py", line 68, in fit
    self.partial_factor_analysis_[name] = fa.fit(X.loc[:, cols])
  File "/home/quadmin/.local/lib/python3.8/site-packages/light_famd/mca.py", line 20, in fit
    self.one_hot_ = one_hot.OneHotEncoder().fit(X)
  File "/home/quadmin/.local/lib/python3.8/site-packages/light_famd/one_hot.py", line 20, in fit
    self.column_names_ = self.get_feature_names(X.columns if hasattr( X,'columns') else None)
AttributeError: 'OneHotEncoder' object has no attribute 'get_feature_names'

System information: