sklego/zero-inflated-roles
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| scikit-lego | error | unsafe, with xpd check --fix --unsafe-fixes |
All versions |
ZeroInflatedRegressor takes the classifier first and the regressor second, so swapping them raises ValueError at fit. Pass a classifier first.
model = ZeroInflatedRegressor(LinearRegression(), LogisticRegression())model = ZeroInflatedRegressor(classifier=LogisticRegression(), regressor=LinearRegression())What the rule reports
Section titled “What the rule reports”The rule reports ZeroInflatedRegressor with a class named like a regressor as the classifier, or
a class named like a classifier as the regressor. The classifier comes first and decides whether a
value is zero, and the regressor comes second.
How to fix it
Section titled “How to fix it”xpd check --fix --unsafe-fixes rewrites a two-argument call whose positional regressor and classifier are swapped to explicit classifier= and regressor= keywords. Fix calls with only one wrong argument by hand.
fit raised ValueError "classifier has to be a classifier", and with a classifier in second
place it raised "regressor has to be a regressor". The rule reads the class names, and it knows
that LogisticRegression is a classifier.
Diagnostic message
Section titled “Diagnostic message”ZeroInflatedRegressor takes the classifier first and the regressor second, and fit raises ValueError "`classifier` has to be a classifier" on $M. Pass classifier= and regressor= in the right roles.See all rules in the scikit-lego pack.