scikit-learn-contrib / category_encoders

A library of sklearn compatible categorical variable encoders
http://contrib.scikit-learn.org/category_encoders/
BSD 3-Clause "New" or "Revised" License
2.39k stars 393 forks source link

Fixed the DataFrame conversion of y in PolynomialWrapper's fit method #432

Closed Asiaticum closed 7 months ago

Asiaticum commented 7 months ago

Fixes #

Proposed Changes

Changed from y = pd.DataFrame(y, columns=['target']) to y = pd.DataFrame(y.rename('target')). This is because if the original y is a pd.Series with a name other than 'target', pd.DataFrame(y, columns=['target']) returns an empty DataFrame.

The root cause of this problem is that in the function of utils.convert_input_vector(y, index) -> pd.Series, when a pd.Series or a single-column pd.DataFrame is passed as an argument, the process is designed to inherit the column name from the column name of the passed pd.Series or pd.DataFrame.

PaulWestenthanner commented 7 months ago

Neat! well spotted. I'll merge it if the pipeline succeeds