MonotoneRepairer#
- class superglm.MonotoneRepairer(direction: str = 'increasing')#
Bases:
objectConstrained fitted-basis projection for monotone spline curves.
- repair(
- spec: _SplineBase,
- beta_reparam: NDArray,
- groups: list[GroupSlice],
- weights: NDArray | None = None,
- n_grid: int = 500,
- metric: NDArray | None = None,
- certificate: ShapeConstraintCertificate | None = None,
Project the fitted spline curve onto the requested monotone cone.
- Parameters:
- spec_SplineBase
The fitted spline spec (with knots, R_inv, etc. already set).
- beta_reparamNDArray
Full model beta (reparametrised space). Slices for this feature are extracted via
groups.- groupslist[GroupSlice]
All groups belonging to this feature (1 for non-select, 2 for select=True).
- weightsNDArray or None
Grid weights (from training data histogram). If None, uniform.
- n_gridint
Number of grid points for curve reconstruction.
- metricNDArray or None
The term’s penalized Hessian
X'WX + S_lambdain its fitted coefficients, with the intercept profiled, asapply_shape_postfitpasses it: the fitted coefficients are projected in it. If None, the curve is projected on the grid, weighted byweights.- certificateShapeConstraintCertificate or None
The fitted coefficients’ shape certificate, where the caller has formed it; formed here if None.
- Returns:
- MonotoneRepairResult