apply_shape_postfit#

SuperLSS.apply_shape_postfit(
X_train: object | EagerFrame | None = None,
*,
n_grid: int = 500,
) → SuperLSS#

Repair every term whose curve breaks its Constraint.postfit rule.

The meaning is superglm.SuperGLM.apply_shape_postfit()’s, for a term of any parameter on that parameter’s link scale: the fitted curve is projected onto the monotone or curvature cone in the term’s own fitted basis, in the fit’s penalized curvature on the term with every other coefficient held and the parameter’s intercept profiled (its posterior precision), and the parameter’s intercept is then re-estimated on the joint likelihood with everything else held. A repair whose penalized objective (the negative log-likelihood plus the fit’s smoothing penalty) is worse than with the term dropped is continued towards the constrained fit, and where no curve the rule allows beats the dropped term, the term is published flat with a RuntimeWarning. A repair that leaves a training row without valid parameters is refused, and nothing is published.

Predictions, curves, coef_ and rating tables follow the repair; result_ and the covariance keep describing the fit. A repaired term reports its EDF, and its standard errors, bands and test are withheld: the projection is a constrained estimator whose reference distribution is not the fit’s. diagnose() reports each repair, and each post-fit rule still waiting for one.

A term that already obeys its rule is left exactly as it is, so a second call repairs nothing; a term edited after its repair so that it breaks the rule again is repaired again, and its new repair replaces the earlier one. The projection reads the training rows: the frame attached at fit, else X_train (the frame given to the fit, or the rows it kept), and the fit must have kept its rows (retain_rows).

Returns:
SuperLSS

The model (self), repaired.