CompactRegressionGAM - Compact generalized additive model (GAM) for regression - MATLAB (original) (raw)

Main Content

Compact generalized additive model (GAM) for regression

Since R2021a

Description

CompactRegressionGAM is a compact version of a RegressionGAM model 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 data.

Creation

Create a CompactRegressionGAM object from a full RegressionGAM model object by using compact.

Properties

expand all

GAM Properties

This property is read-only.

Data Types: double

This property is read-only.

Intercept (constant) term of the model, which is the sum of the intercept terms in the predictor trees and interaction trees, specified as a numeric scalar.

Data Types: single | double

Flag indicating whether a model for the standard deviation of the response variable is fit, specified as false or true. Specify the 'FitStandardDeviation' name-value argument offitrgam as true to fit the model for the standard deviation.

If IsStandardDeviationFit is true, then you can evaluate the standard deviation at a new observation by using predict. This function also returns the prediction intervals of the response variable, evaluated at given observations.

Data Types: logical

Other Regression Properties

This property is read-only.

Categorical predictor indices, specified as a vector of positive integers. CategoricalPredictors contains index values indicating that the corresponding predictors are categorical. The index values are between 1 and p, where p is the number of predictors used to train the model. If none of the predictors are categorical, then this property is empty ([]).

Data Types: double

This property is read-only.

Data Types: cell

This property is read-only.

Predictor variable names, specified as a cell array of character vectors. The order of the elements in PredictorNames corresponds to the order in which the predictor names appear in the training data.

Data Types: cell

This property is read-only.

Response variable name, specified as a character vector.

Data Types: char

Data Types: char | string | function_handle

Object Functions

expand all

predict Predict responses using generalized additive model (GAM)
loss Regression loss for generalized additive model (GAM)

Examples

collapse all

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.

Load the carbig data set.

Specify Acceleration, Displacement, Horsepower, and Weight as the predictor variables (X) and MPG as the response variable (Y).

X = [Acceleration,Displacement,Horsepower,Weight]; Y = MPG;

Train a GAM using X and 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 = 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 597222 classreg.learning.regr.CompactRegressionGAM
Mdl 1x1 631046 RegressionGAM

The full model (Mdl) is larger than the compact model (CMdl).

To efficiently predict responses for new observations, you can remove Mdl from the MATLABĀ® Workspace, and then pass CMdl and new predictor values to predict.

Version History

Introduced in R2021a