MaxHalford / prince

:crown: Multivariate exploratory data analysis in Python — PCA, CA, MCA, MFA, FAMD, GPA
https://maxhalford.github.io/prince
MIT License
1.27k stars 184 forks source link

FAMD fit method not compatible with scikit-learn pipeline #165

Closed ustcwxz closed 1 year ago

ustcwxz commented 1 year ago
X_train, X_test, y_train, y_test = train_test_split(X, y)
pip = Pipeline(steps=[('transformer', prince.FAMD(n_components=13)), ('estimator', DecisionTreeRegressor())])
pip.fit(X=X_train, y=y_train)

X is a pandas DataFrame y is a pandas Series The fit method throw error "ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."

That because the pipeline's fit method need params "res = transformer.fit_transform(X, y, **fit_params)"

MaxHalford commented 1 year ago

Hey there @ustcwxz. Thanks for opening this issue.

I just fixed this in version 0.12.1, which has just been released. Let me know if something is wrong :)

ustcwxz commented 1 year ago

Thanks! It's working great now!