CubicRegressionSpline#

class superglm.CubicRegressionSpline(
n_knots: int = 10,
knot_strategy: str = 'uniform',
penalty: str = 'ssp',
select: bool = False,
knots: ArrayLike | None = None,
discrete: bool | None = None,
n_bins: int | None = None,
extrapolation: str = 'clip',
boundary: tuple[float, float] | None = None,
knot_alpha: float = 0.2,
constraint=None,
m: int | tuple[int, ...] = 2,
lambda_policy: LambdaPolicy | dict[str, LambdaPolicy] | None = None,
polynomial_ranges: Sequence[PolynomialRange] | None = None,
)#

Bases: _IntegratedPenaltySpline

CR spline: integrated f’’ squared penalty + natural boundary constraints.

Compatible with the standard cubic regression spline construction used in GAM packages. Always cubic (degree=3). Natural boundary constraints (f’’=0 at boundaries) are mandatory. The basis has linear tails, but default prediction still clips at the training boundary unless extrapolation="extend" is used.

The penalty matrix is the wiggliness penalty: omega_ij = int B_i’’(x) B_j’’(x) dx, computed via Gauss-Legendre quadrature over each knot interval.

Multi-order penalties (m tuple) are a SuperGLM extension, not strict mgcv bs="cr" parity.

Parameters:
constraintConstraintSpec or None

Public shape-constraint token. Use Constraint.fit.increasing, Constraint.fit.decreasing, Constraint.fit.convex, Constraint.fit.concave, or any of the corresponding Constraint.postfit.* kinds. Fit-time constraints apply on the spline term’s linear-predictor contribution and use the constrained QP solver path. With fit_reml(), fixed lambdas work directly; automatic lambda estimation uses the QP passthrough heuristic (unconstrained REML followed by constrained refit), not exact joint constrained REML.

polynomial_rangessequence of PolynomialRange or None

Ranges of the axis on which the curve is pinned to a polynomial of the range’s degree; the rest stays the penalised smooth, and the penalty skips the pinned intervals. A range reaching an end replaces that end’s natural condition.