skfolio/skfolio-string-enum-option
| Rule | skfolio-string-enum-option |
|---|---|
| Pack | skfolio |
| Severity | error |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | skfolio 1.14.4 and later |
skfolio expects enum members for risk measures and objectives. It uses methods and properties on those members during fit.
MeanRisk(risk_measure='variance', objective_function='minimize_risk')MeanRisk(risk_measure=RiskMeasure.VARIANCE, objective_function=ObjectiveFunction.MINIMIZE_RISK)What the rule reports
Section titled “What the rule reports”Import RiskMeasure from skfolio.measures and ObjectiveFunction from skfolio.optimization.
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to convert string risk_measure and objective_function values to RiskMeasure and ObjectiveFunction enum members when those enums are imported.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
A string risk_measure such as 'variance' raises AttributeError during skfolio fit. Pass a RiskMeasure member.Browse the other rules of the skfolio pack.