rules/mapie/predict-function-returns-labels.md
BinaryClassificationController needs a function that returns class probabilities, and predict returns labels, so calibrate raises IndexError. Pass model.predict_proba.
| 1 | -controller = BinaryClassificationController(model.predict, "precision", target_level=0.8) |
| 2 | +controller = BinaryClassificationController(model.predict_proba, "precision", target_level=0.8) |
What the rule reports
The rule reports BinaryClassificationController with model.predict as its predict_function.
The rule skips expected-error and expected-warning checks such as pytest.raises and pytest.warns.
How to fix it
xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.
The unsafe fix writes model.predict_proba.
With model.predict, calibrate raised IndexError, "Error when calling the predict_function",
because the controller reads the probability of the positive class from the second column.
MultiLabelClassificationController ran with predict, so the rule leaves it alone.