monotonize#

SuperGLM.monotonize(
X: object,
sample_weight: NDArray | None = None,
offset: NDArray | None = None,
*,
n_grid: int = 500,
) → SuperGLM#

Repair post-fit shape-constrained spline terms after fitting.

This is a manual, post-fit repair step. It finds all spline features configured with Constraint.postfit.*, applies the corresponding weighted shape projection to the fitted curve, and projects the repaired curve back to spline coefficients.

Idempotent: calling twice does not re-repair already-repaired features.

Parameters:
Xpandas or eager Polars DataFrame

Training data (used to compute density-based grid weights).

sample_weightarray-like, optional

Fitting weights used to weight the post-fit projection, read under the model’s declared weight_semantics: replication counts under "frequency", precisions under "prior".

offsetarray-like, optional

Offset term (unused, reserved for deviance computation).

n_gridint

Grid resolution for the shape repair (default 500).

Returns:
SuperGLM

The model (self), with post-fit shape repairs stored.