rules/sklego/monotonic-spline-without-positive.md

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.

diff
1-pipe = make_pipeline(MonotonicSplineTransformer(n_knots=5), Ridge(alpha=1.0))
2+pipe = make_pipeline(MonotonicSplineTransformer(n_knots=5), Ridge(alpha=1.0, positive=True))

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

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.