Compact linear regression model
Compact Linear Regression Model
Fit a linear regression model to data and reduce the size of a full, fitted linear regression model by discarding the sample data and some information related to the fitting process.
largedata4reg data set, which contains 15,000 observations and 45 predictor variables.
Fit a linear regression model to the data.
mdl = fitlm(X,Y);
Compact the model.
compactMdl = compact(mdl);
The compact model discards the original sample data and some information related to the fitting process.
Compare the size of the full model
mdl and the compact model
vars = whos('compactMdl','mdl'); [vars(1).bytes,vars(2).bytes]
ans = 1×2 81537 11409064
The compact model consumes less memory than the full model.
compactMdl — Compact linear regression model
Compact linear regression model, returned as a
CompactLinearModel object consumes less memory than a
LinearModel object because a compact model does not
store the input data used to fit the model or information related to the
fitting process. You can still use a compact model to predict responses
using new input data, but some
LinearModel object functions
do not work with a compact model.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).