skfolio/skfolio-sklearn-cross-val-predict
| Rule | skfolio-sklearn-cross-val-predict |
|---|---|
| Pack | skfolio |
| Severity | warning |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | skfolio 1.14.4 and later |
scikit-learn's cross_val_predict can reject skfolio financial splitters or convert portfolio predictions to a NumPy array.
from sklearn.model_selection import cross_val_predictresult = cross_val_predict(model, returns, cv=walk)from skfolio.model_selection import cross_val_predictresult = cross_val_predict(model, returns, cv=walk)What the rule reports
Section titled “What the rule reports”skfolio returns a MultiPeriodPortfolio for WalkForward and a Population for combinatorial or randomized portfolio backtests. Check downstream code when changing the return type.
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to call cross_val_predict from skfolio.model_selection when it is imported.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
scikit-learn cross_val_predict raises ValueError with WalkForward, CombinatorialPurgedCV and MultipleRandomizedCV in skfolio. Use skfolio.model_selection.cross_val_predict.Browse the other rules of the skfolio pack.