models.GamFit
A fitted GAM, from Gam.fit.
Usage
models.GamFit()Attributes
| Name | Description |
|---|---|
| aic |
-2 log_likelihood + 2 edf, not counting an estimated dispersion,
|
| coefficients | Coefficients. |
| deviance | Residual deviance. |
| dispersion | Dispersion. |
| edf | Effective degrees of freedom. |
| fitted | Fitted means on the training data. |
| input_hash | Hash of the training data (design, offset, weights, response). |
| lambdas | Smoothing parameter of each smooth. |
| log_likelihood | Log-likelihood at the fitted means and the dispersion, as |
| names |
Coefficient names: parametric columns, then s(x).1, …
|
| reml_scale | The dispersion REML estimates with the smoothing parameters |
| score |
The minimized GCV, UBRE or REML score (mgcv’s gcv.ubre).
|
aic
-2 log_likelihood + 2 edf, not counting an estimated dispersion,
aic: float
as GlmFit.aic (mgcv’s AIC adds 1 when the scale is estimated).
coefficients
Coefficients.
coefficients: list[float]
deviance
Residual deviance.
deviance: float
dispersion
Dispersion.
dispersion: float
edf
Effective degrees of freedom.
edf: float
fitted
Fitted means on the training data.
fitted: list[float]
input_hash
Hash of the training data (design, offset, weights, response).
input_hash: str
lambdas
Smoothing parameter of each smooth.
lambdas: list[float]
log_likelihood
Log-likelihood at the fitted means and the dispersion, as
log_likelihood: float
GlmFit.log_likelihood (the Gaussian’s at the maximum-likelihood variance). NaN for a fit loaded from an older artifact.
names
Coefficient names: parametric columns, then s(x).1, …
names: list[str]
reml_scale
The dispersion REML estimates with the smoothing parameters
reml_scale: float | None
(mgcv’s reml.scale), or None for GCV and UBRE.
score
The minimized GCV, UBRE or REML score (mgcv’s gcv.ubre).
score: float
Methods
| Name | Description |
|---|---|
| from_json() | Reads an artifact written by to_json. |
| predict() | Expected response for each row. |
| predict_distribution() | Joint predictive distribution across the rows, keyed row. |
| to_json() | The fit as a versioned JSON artifact (GLM spec, smooths with their knots and constraints, smoothing parameters, estimates), with provenance (crate |
from_json()
Reads an artifact written by to_json.
Usage
from_json(text)Parameters
text: str
Returns
GamFit
Raises
ValueError- For malformed JSON, another format, a newer format version or inconsistent fields.
predict()
Expected response for each row.
Usage
predict(design)Parameters
design: Design- Same columns as the training design, raw smooth columns included.
Returns
list of float
predict_distribution()
Joint predictive distribution across the rows, keyed row.
Usage
predict_distribution(design, n_sims, seed)Parameters
design: Designn_sims: intseed: int
Returns
PredictiveDistribution
to_json()
The fit as a versioned JSON artifact (GLM spec, smooths with their knots and constraints, smoothing parameters, estimates), with provenance (crate
Usage
to_json()version and a hash of the training data). GamFit.from_json reads it back exactly; pickling uses it too.
Returns
str