-
gammy.models.numpy.GAM
GAM¶
-
class
GAM(formula, tau, theta=None)[source]¶ Bases:
objectGeneralized additive model with NumPy backend
- Parameters
- formulagammy.formulae.Formula
Formula object containing the terms and prior
- thetaGaussian
Model parameters vector
- tauDelta
Observation noise precision (inverse variance)
-
property
covariance_theta¶ Covariance estimate of model parameters
-
fit(input_data, y) → gammy.models.numpy.GAM[source]¶ Estimate model parameters
- Parameters
- input_datanp.ndarray
Input data
- ynp.ndarray
Observations
-
formula¶ Model formula
-
property
inv_mean_tau¶ Additive observation noise variance estimate
-
load(filepath: str) → gammy.models.numpy.GAM[source]¶ Load model from a file on disk
-
marginal_residual(input_data, y, i: int) → numpy.ndarray[source]¶ Calculate marginal residual for a given term
- Parameters
- input_datanp.ndarray
Input data
- ynp.ndarray
Observations
-
marginal_residuals(input_data, y) → List[numpy.ndarray][source]¶ Marginal (partial) residuals
- Parameters
- input_datanp.ndarray
Input data
- ynp.ndarray
Observations
-
property
mean_theta¶ Mean estimate of model parameters
Posterior if model is fitted, otherwise prior.
-
predict(input_data) → numpy.ndarray[source]¶ Calculate mean of posterior predictive at inputs
- Parameters
- input_datanp.ndarray
-
predict_marginal(input_data, i: int) → numpy.ndarray[source]¶ Predict a term separately
- Parameters
- input_datanp.ndarray
-
predict_marginals(input_data) → List[numpy.ndarray][source]¶ Predict all terms separately
- Parameters
- input_datanp.ndarray
-
predict_variance(input_data) → Tuple[numpy.ndarray][source]¶ Predict mean and variance
- Parameters
- input_datanp.ndarray
-
predict_variance_marginal(input_data, i: int) → Tuple[numpy.ndarray][source]¶ Evaluate mean and variance for a given term
- Parameters
- input_datanp.ndarray
-
predict_variance_marginals(input_data) → List[Tuple[numpy.ndarray]][source]¶ Predict variance (theta) for marginal parameter distributions
- Parameters
- input_datanp.ndarray
-
predict_variance_theta(input_data) → Tuple[numpy.ndarray][source]¶ Predict observations with variance from model parameters
- Parameters
- input_datanp.ndarray
-
tau¶ Additive noise precision parameter
-
theta¶ Model parameters
-
theta_marginal(i: int) → gammy.models.numpy.Gaussian[source]¶ Extract marginal distribution for a specific term
-
property
theta_marginals¶ Marginal distributions of model parameters