s#
- superglm.s(
- column: str,
- *,
- kind: str = 'ps',
- k: int | None = None,
- n_knots: int | None = None,
- 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: ConstraintSpec | None = None,
- m: int | tuple[int, ...] = 2,
- lambda_policy: LambdaPolicy | dict[str, LambdaPolicy] | None = None,
Describe a smooth effect of one numeric column.
For example,
s("age", kind="cr", k=10)declares a cubic regression spline inside a family predictor. The model learns its basis and coefficients when fitted. All spline options have the same meaning as inSpline.- Parameters:
- columnstr
Name of the numeric input column.
- kindstr, default=”ps”
Spline basis. Common choices are
"ps"for P-splines and"cr"for cubic regression splines. SeeSplinefor the other bases.- kint, optional
Public basis size. This limits flexibility; it is not the fitted effective degrees of freedom. Supply either
korn_knots.- n_knotsint, optional
Number of interior knots, as an alternative to
k.- degreeint, default=3
Polynomial degree for bases that support this option. Cubic regression splines remain cubic.
- knot_strategystr, default=”uniform”
Knot-placement rule.
"uniform"spaces knots evenly;"quantile_rows"follows the training data and"quantile_tempered"tempers that concentration.- penalty{“ssp”, “none”}, default=”ssp”
Enable SSP basis reparametrization, or disable it with
"none".- selectbool, default=False
Add a penalty on the spline’s null space so that smoothing can also shrink directions left unpenalized by the ordinary wiggle penalty.
- knotsarray-like, optional
Explicit interior knot positions, replacing automatic placement.
- discretebool, optional
Request discrete evaluation for this term.
Noneinherits the model setting.- n_binsint, optional
Bin count for discrete evaluation.
Noneinherits the model setting.- extrapolation{“clip”, “extend”, “error”}, default=”clip”
Prediction outside the fitted boundaries: hold the boundary value, continue the basis, or raise an error.
- boundarytuple of float, optional
Explicit lower and upper spline boundaries. Otherwise use the training range.
- knot_alphafloat, default=0.2
Tempering control for
"quantile_tempered"knot placement.- constraintConstraintSpec, optional
Requested shape constraint. See the SuperLSS limitation below.
- mint or tuple of int, default=2
Penalty order: a difference order for P-splines or a derivative order for derivative-penalty bases. Multiple orders require a basis that supports multiple penalty components.
- lambda_policyLambdaPolicy or dict of str to LambdaPolicy, optional
Control whether smoothing penalties are estimated or fixed. A mapping sets policies for the spline’s individual penalty components.
- Returns:
- BoundTerm
A spline declaration for the named column.
See also
Notes
SuperLSScurrently warns and fits unconstrained when a term requests shape constraints. Aconstraintargument does not enforce them there.Examples
>>> from superglm import s >>> age = s("age", kind="cr", k=10) >>> age.column 'age'