Skip to content

sklego/zero-inflated-roles

Rule zero-inflated-roles
Pack scikit-lego
Severity error
Fix none, edit by hand
Library versions every version

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())

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.

xpd has no automatic fix, so make the change 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.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

ZeroInflatedRegressor takes the classifier first and the regressor second, and fit raises ValueError "`classifier` has to be a classifier" on $M. Pass a classifier there.

Browse the other rules of the scikit-lego pack.