BSplineSmooth#

class superglm.BSplineSmooth(
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,
constraint=None,
m: int | tuple[int, ...] = 2,
lambda_policy: LambdaPolicy | dict[str, LambdaPolicy] | None = None,
polynomial_ranges: Sequence[PolynomialRange] | None = None,
)#

Bases: _IntegratedPenaltySpline, _BSplineBase

B-spline smooth: B-spline basis with an integrated-derivative penalty.

Same raw B-spline basis as PSpline, but penalised via the integrated squared m-th derivative rather than the discrete difference penalty. This is the analogue of mgcv’s "bs" smooth.

The penalty matrix is:

omega_ij = int B_i^(m)(x) B_j^(m)(x) dx

computed by Gauss–Legendre quadrature over each knot span. m is the integrated derivative order (default 2 = integrated second-derivative penalty). Compare with PSpline where m is the finite-difference order on the coefficient vector.

Cubic by default (degree=3) but general degree is allowed.

Parameters:
n_knotsint

Number of interior knots.

degreeint

B-spline polynomial degree.

knot_strategystr

"uniform" or "quantile".

penaltystr

"ssp" enables SSP reparametrisation, "none" for raw.

selectbool

If True, add double-penalty shrinkage (null + range space).

knotsarray-like or None

Explicit interior knot positions.

constraintConstraintSpec or None

Public shape-constraint token. Use Constraint.fit.increasing, Constraint.fit.decreasing, Constraint.fit.convex, Constraint.fit.concave, Constraint.postfit.increasing, Constraint.postfit.decreasing, Constraint.postfit.convex, or Constraint.postfit.concave. For BSplineSmooth, fit-time monotone and curvature 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. Fit-time convexity/concavity is supported for degrees one through three; higher degrees require a Constraint.postfit.* token.

mint or tuple of int

Integrated derivative order(s) for the penalty.

lambda_policyLambdaPolicy or dict or None

Per-component lambda control.

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.