Compact generalized additive model (GAM) for regression
CompactRegressionGAM is a compact version of a
object (GAM for regression). The compact model does not include the data used for training the
model. Therefore, you cannot perform some tasks, such as cross-validation, using the compact
model. Use a compact model for tasks such as predicting the responses of new
CompactRegressionGAM object from a full
object by using
IsStandardDeviationFit — Flag indicating whether standard deviation model is fit
Flag indicating whether a model for the standard deviation of the response
variable is fit, specified as
'FitStandardDeviation' name-value argument of
true to fit the model for the
you can evaluate the standard deviation at a new observation by using
This function also returns the prediction intervals of the response variable,
evaluated at given observations.
Other Regression Properties
CategoricalPredictors — Categorical predictor indices
vector of positive integers |
This property is read-only.
indices, specified as a vector of positive integers.
contains index values indicating that the corresponding predictors are categorical. The index
values are between 1 and
p is the number of
predictors used to train the model. If none of the predictors are categorical, then this
property is empty (
ResponseName — Response variable name
This property is read-only.
Response variable name, specified as a character vector.
|Local interpretable model-agnostic explanations (LIME)|
|Compute partial dependence|
|Plot local effects of terms in generalized additive model (GAM)|
|Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots|
Reduce Size of Generalized Additive Model
Reduce the size of a full generalized additive model (GAM) for regression by removing the training data. Full models hold the training data. You can use a compact model to improve memory efficiency.
carbig data set.
Weight as the predictor variables (
MPG as the response variable (
X = [Acceleration,Displacement,Horsepower,Weight]; Y = MPG;
Train a GAM using
Mdl = fitrgam(X,Y)
Mdl = RegressionGAM ResponseName: 'Y' CategoricalPredictors:  ResponseTransform: 'none' Intercept: 26.9442 IsStandardDeviationFit: 0 NumObservations: 398 Properties, Methods
Mdl is a
RegressionGAM model object.
Reduce the size of the model.
CMdl = compact(Mdl)
CMdl = CompactRegressionGAM ResponseName: 'Y' CategoricalPredictors:  ResponseTransform: 'none' Intercept: 26.9442 IsStandardDeviationFit: 0 Properties, Methods
CMdl is a
CompactRegressionGAM model object.
Display the amount of memory used by each regression model.
Name Size Bytes Class Attributes CMdl 1x1 578163 classreg.learning.regr.CompactRegressionGAM Mdl 1x1 611957 RegressionGAM
The full model (
Mdl) is larger than the compact model (
To efficiently predict responses for new observations, you can remove
Mdl from the MATLAB® Workspace, and then pass
CMdl and new predictor values to
Introduced in R2021a