Skip to content

scikit-lego

The scikit-lego pack catches silent argument mistakes, pipeline ordering traps, broken scorer calls, and removed or superseded scikit-lego 0.9 APIs on files that import sklego. Rules fire only on names bound to sklego imports.

Rules Safe fix Unsafe fix Manual fix
25 1 15 9
Rule Severity Fix What it finds
thresholder-score error unsafe Thresholder.score ignores the threshold, so a search over thresholds scores every one the same.
estimator-transformer-proba error none EstimatorTransformer reshapes its output to one column, so predict_proba comes back with twice as many rows and a pipeline around it raises.
column-capper-fraction error unsafe ColumnCapper reads quantile_range in percent, so (0.05, 0.95) caps almost every value at a percentile below 1.
dict-mapper-not-int error none DictMapper casts every mapped value to int, so a float loses its fraction without a warning.
regression-outlier-column-name error none RegressionOutlierDetector with a column name keeps the target among the features, so the inner model predicts the target from itself.
pca-outlier-after-scaler error none After a centring step such as StandardScaler, the default relative error of PCAOutlierDetection divides by numbers near zero and flags many normal rows.
outlier-threshold error unsafe These outlier detectors need a valid threshold, and fit raises ValueError without one or with one out of range.
grouped-shrinkage-arguments error unsafe GroupedClassifier drops a shrinkage keyword without an error, so the setting has no effect.
interval-encoder-ignored-span error none sklego.preprocessing.IntervalEncoder uses span only for method="normal" and silently ignores it for method="increasing" or method="decreasing".
monotonic-spline-without-positive warning none MonotonicSplineTransformer integrates B-splines into monotone I-spline basis columns.
Rule Severity Fix What it finds
add-lags-positive warning unsafe add_lags with a positive lag copies the value of a later row, so lag 1 is the next row and leaks the future into the features.
decay-on-shuffled-rows warning unsafe DecayEstimator gives the last rows the most weight, and train_test_split shuffles the rows, so the weights no longer follow time.
outlier-remover-before-model error none OutlierRemover drops rows of X and leaves y whole, so the model after it raises ValueError.
decay-without-sample-weight error unsafe DecayEstimator passes sample_weight to the fit of the model it wraps, so wrapping a Pipeline or a model without sample_weight raises ValueError.
zero-inflated-roles error unsafe ZeroInflatedRegressor takes the classifier first and the regressor second, so swapping them raises ValueError at fit.
Rule Severity Fix What it finds
scorer-called-as-metric error unsafe These fairness functions return a scorer that takes an estimator, so wrapping them in make_scorer or calling them on labels raises and makes every score NaN.
dataset-frame-and-xy error none With as_frame=True, the scikit-lego loaders ignore return_X_y=True and return one frame with the target in it, so unpacking into X and y raises ValueError.
log-step-extra-bare error unsafe A bare @log_step_extra takes the decorated function as a log function, so calling the function returns another function and not a frame.
selector-without-feature-names error none ColumnSelector, ColumnDropper and TypeSelector have no set_output and no get_feature_names_out, so calling either on a pipeline that holds them raises.
debug-pipeline-default-log info unsafe log_callback="default" logs at level INFO, which Python hides until logging is set up, so the pipeline prints nothing.
Rule Severity Fix What it finds
removed-in-sklego error unsafe These forms were removed from scikit-lego, so the import or the call raises.
deprecated-in-sklego warning safe These names, keywords and attributes warn on scikit-lego and will be removed.
superseded-estimator warning unsafe scikit-lego warns on these classes and asks you to use a replacement, such as scikit-learn's QuantileRegressor.
Rule Severity Fix What it finds
group-time-series-split-folds warning unsafe GroupTimeSeriesSplit tries every combination of split points, so each extra fold multiplies the time, from about 1 second at 5 folds to 10 at 6.
unseeded-random-estimator info unsafe RandomRegressor and RandomAdder without random_state draw new numbers on every call, so results change between calls.