sklego/monotonic-spline-without-positive
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| scikit-lego | warning | none, edit by hand | All versions |
MonotonicSplineTransformer integrates B-splines into monotone I-spline basis columns. A downstream linear model with unconstrained signs can assign negative weights to individual basis functions and violate monotonicity.
pipe = make_pipeline(MonotonicSplineTransformer(n_knots=5), Ridge(alpha=1.0))pipe = make_pipeline(MonotonicSplineTransformer(n_knots=5), Ridge(alpha=1.0, positive=True))What the rule reports
Section titled “What the rule reports”Pipeline, make_pipeline, DebugPipeline, or make_debug_pipeline calls combining MonotonicSplineTransformer with a linear regressor (LinearRegression, Ridge, Lasso, LassoCV, ElasticNet, ElasticNetCV, LADRegression, QuantileRegression, ImbalancedLinearRegression) that omits positive=True.
How to fix it
Section titled “How to fix it”Pass positive=True to the linear regressor to enforce non-negative spline weights, or add # ast-grep-ignore: sklego/monotonic-spline-without-positive with a reason if non-monotone combinations are intentional.
Diagnostic message
Section titled “Diagnostic message”MonotonicSplineTransformer produces monotone I-spline bases whose prediction monotonicity holds only when the linear model constrains coefficients with positive=True. Pass positive=True on the linear regressor or document why unconstrained signs are intended.See all rules in the scikit-lego pack.