magli.wood.LinGAM

class magli.wood.LinGAM(n_splines: int = 10, lam: float | None = None, spline_order: int = 3, constraint: str | None = None, k: int | None = None, sp: float | None = None, bs: str = 'tp', method: str = 'REML', gamma: float = 1.0)[source]

Penalised GAM for a single smooth term y = beta_0 + f(x) + eps (Wood backend).

property n_splines: int
property k: int
property lam: float | None
property sp: float | None
property bs: str
property n_coefs: int

Effective number of model coefficients (smooth + intercept).

property design_matrix_: ndarray | None
fit(x: ArrayLike, y: ArrayLike, weights: ArrayLike | None = None) → LinGAM[source]

Fit the GAM model using Wood REML or GCV criteria.

aic() → float

Akaike Information Criterion (AIC).

bic() → float

Bayesian Information Criterion (BIC).

coef_: ndarray | None = None
confidence_intervals(x: ArrayLike, width: float = 0.95) → ndarray

Compute confidence intervals for the linear predictor.

deviance_explained() → float

Fraction of null deviance explained (pseudo R-squared).

fit_intercept: bool = True
formula: str = ''
gridsearch(x: ArrayLike, y: ArrayLike, n_splines: ArrayLike | None = None, lam: ArrayLike | None = None, gamma: float = 1.0, weights: ArrayLike | None = None) → LinGAM[source]

Select optimal basis dimension k (and optionally lam) via REML or GCV.

property is_fitted: bool
loglikelihood() → float

Gaussian log-likelihood of the fitted model.

property n_terms: int
partial_dependence(term_idx: int, x: ArrayLike) → ndarray

Evaluate the partial contribution of term term_idx.

plot_diagnostics(x: ArrayLike, y: ArrayLike, figsize: Tuple[int, int] | None = None) → Tuple[Any, ndarray]

Diagnostic plots for model validation.

predict(x: ArrayLike) → ndarray

Predict target values for feature data x.

prediction_intervals(x: ArrayLike, width: float = 0.95) → ndarray

Compute prediction intervals for new observations.

statistics_: Dict[str, Any] | None = None
summary() → str

Formatted summary table for the fitted Wood GAM.

plot_decomposition(x: ArrayLike, y: ArrayLike, n_grid: int = 300, figsize: Tuple[int, int] = (16, 5), show_weighted: bool = False) → Tuple[source]

Plot basis decomposition, coefficients, and overall fit.