models.Gam
A generalized additive model: a Glm plus P-spline smooths of
Usage
models.Gam()numeric design columns, with smoothing chosen by GCV or UBRE.
Parameters
glm: Glm-
Family, link and dispersion.
smooths: list of str, (str, int) or dict-
The design columns to smooth, optionally with the number of basis functions (10 by default), or a dict
{"column": ..., "n_basis": ..., "bs": ..., "period": ...}:bsis"ps"(the default) or"cp"for a cyclic smooth (mgcv’sbs = "cp"), whose ends meet over period, a(lo, hi)pair (the data’s range when left out), or"mpi"/"mpd"for a monotone increasing or decreasing smooth (scam’s), which takes GCV, UBRE or fixed smoothing but not REML. smoothing: str or list of float = "auto"-
"auto"(UBRE for a fixed dispersion, GCV otherwise),"gcv","ubre","reml"(mgcv’smethod = "REML", estimating an unknown dispersion with the smoothing parameters), or fixed smoothing parameters: one per smooth, then one per tensor margin. tensors: list-
Tensor product smooths (mgcv’s
te(..., bs = "ps", np = FALSE)): each a list of two or more column names, or(columns, n_basis)with one basis size per column (5 by default). Each margin has its own smoothing parameter.
Examples
>>> import math
>>> from prospicio.models import Design, Gam, Glm
>>> x = [i / 99 for i in range(100)]
>>> y = [math.sin(6 * v) for v in x]
>>> d = Design([[1.0] * 100, x], ["(Intercept)", "x"])
>>> fit = Gam(Glm("gaussian"), ["x"]).fit(d, y)
>>> abs(fit.predict(d)[50] - y[50]) < 0.01True
Methods
| Name | Description |
|---|---|
| fit() | Fits the model. |
fit()
Fits the model.
Usage
fit(design, y)Parameters
design: Design-
Includes the raw columns to smooth.
y: list of float
Returns
GamFit