NaturalSpline#

class superglm.NaturalSpline(
n_knots: int = 10,
degree: int = 3,
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,
m: int | tuple[int, ...] = 2,
lambda_policy: LambdaPolicy | dict[str, LambdaPolicy] | None = None,
)#

Bases: _SplineBase

Natural P-spline: f’’=0 at boundaries, linear tails.

Applies natural boundary constraints: f’’(boundary) = 0 at both ends. The underlying basis therefore has linear tails beyond the boundary knots, preventing the tail explosions common with unconstrained B-splines. Prediction behavior outside the training range is then controlled by extrapolation: "clip" (default) freezes at the boundary, while "extend" exposes the linear tails.

Uses a second-difference penalty (like BS) rather than the integrated-f’’ penalty of CubicRegressionSpline. The boundary constraints reduce the penalty null space to 1 dimension (constant only), so select=True is not supported — use kind="cr" or kind="ps" for double-penalty selection.