sklego/estimator-transformer-proba
| Rule | estimator-transformer-proba |
|---|---|
| Pack | scikit-lego |
| Severity | error |
| Fix | none, edit by hand |
| Library versions | every version |
EstimatorTransformer reshapes its output to one column, so predict_proba comes back with twice as many rows and a pipeline around it raises. Use predict_func="decision_function" for a binary model, or scikit-learn's StackingClassifier.
features = EstimatorTransformer(LogisticRegression(), predict_func="predict_proba")features = EstimatorTransformer(LogisticRegression(), predict_func="decision_function")stack = StackingClassifier([("lr", LogisticRegression())], stack_method="predict_proba")What the rule reports
Section titled “What the rule reports”The rule reports EstimatorTransformer(..., predict_func="predict_proba") and
"predict_log_proba". When the target has one dimension, the transformer reshapes the output to
one column, so the probabilities of the two classes stack into twice as many rows.
How to fix it
Section titled “How to fix it”xpd has no automatic fix, so make the change by hand.
A binary model on 400 rows came back from transform with the shape (800, 1). Inside a
FeatureUnion, and inside a pipeline before a model, fit raised ValueError on the row counts.
decision_function gave (400, 1), and StackingClassifier(stack_method="predict_proba").transform
gave one row per input row.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
EstimatorTransformer reshapes the output to one column, so predict_proba on 400 rows came back with the shape (800, 1), and a pipeline around it raised ValueError. Use predict_func="decision_function" for a binary model, or scikit-learn's StackingClassifier(stack_method="predict_proba").Browse the other rules of the scikit-lego pack.