TermsPredictionResult

Container returned by GAM.predict(type="terms").

Usage

Source

TermsPredictionResult(
    terms,
    se,
    labels=list(),
)

Instead of collapsing every smooth’s effect into a single linear predictor, each smooth term’s contribution is kept separate. This is useful for decomposing a fitted additive model into its constituent partial effects (e.g., to inspect how much of the prediction at a point comes from s(x1) versus s(x2)) without needing to build partial-effect plots.

Attributes

terms: dict[str, numpy.ndarray]

Maps each term label (e.g. "s(x1)", "te(x1, x2)", or "s(x1):group_a" for factor-by smooths) to that term’s contribution to the linear predictor, each of shape (n,). Contributions sum (plus the intercept and any parametric terms) to the full linear predictor.

se: dict[str, numpy.ndarray] or None

Maps each term label to its per-term standard error, each of shape (n,). None unless se=True was passed to predict().

labels: list[str]
Term labels in formula order, matching the keys of terms and se.

Attributes

Name Description
values Sum of all term contributions (overall linear predictor).

values

Sum of all term contributions (overall linear predictor).

values: NDArray