CompactRegressionEnsemble - Compact regression ensemble - MATLAB (original) (raw)
Compact regression ensemble
Description
Compact version of a regression ensemble. The compact version does not include the data for training the regression ensemble. Therefore, you cannot perform some tasks with a compact regression ensemble, such as cross validation. Use a compact regression ensemble for making predictions (regressions) of new data.
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: single
| double
This property is read-only.
Method used to combine weak learner weights, returned as either'WeightedAverage'
or 'WeightedSum'
.
Data Types: char
This property is read-only.
Expanded predictor names, returned as a cell array of character vectors.
If the model uses encoding for categorical variables, thenExpandedPredictorNames
includes the names that describe the expanded variables. Otherwise, ExpandedPredictorNames
is the same asPredictorNames
.
Data Types: cell
This property is read-only.
Number of trained weak learners in the ensemble, returned as a positive integer.
Data Types: double
This property is read-only.
Predictor names, specified as a cell array of character vectors. The order of the entries in PredictorNames
is the same as in the training data.
Data Types: cell
This property is read-only.
Name of the response variable, returned as a character vector.
Data Types: char
Data Types: char
| string
| function_handle
This property is read-only.
Trained weak learners, returned as a cell vector. The entries of the cell vector contain the corresponding compact regression models.
Data Types: cell
This property is read-only.
Trained weak learner weights, returned as a numeric vector. TrainedWeights
has NumTrained
elements, whereNumTrained
is the number of weak learners in the ensemble. The ensemble computes the predicted response by aggregating weighted predictions from its learners.
Data Types: double
Object Functions
gather | Gather properties of Statistics and Machine Learning Toolbox object from GPU |
---|---|
lime | Local interpretable model-agnostic explanations (LIME) |
loss | Regression error for regression ensemble model |
partialDependence | Compute partial dependence |
plotPartialDependence | Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots |
predict | Predict responses using regression ensemble model |
predictorImportance | Estimates of predictor importance for regression ensemble of decision trees |
removeLearners | Remove members of compact regression ensemble |
shapley | Shapley values |
Examples
Create a compact regression ensemble for efficiently making predictions on new data.
Load the carsmall
data set. Consider a model that explains a car's fuel economy (MPG
) using its weight (Weight
) and number of cylinders (Cylinders
).
load carsmall X = [Weight Cylinders]; Y = MPG;
Train a boosted ensemble of 100 regression trees using the LSBoost
. Specify that Cylinders
is a categorical variable.
Mdl = fitrensemble(X,Y,'PredictorNames',{'W','C'},... 'CategoricalPredictors',2)
Mdl = RegressionEnsemble PredictorNames: {'W' 'C'} ResponseName: 'Y' CategoricalPredictors: 2 ResponseTransform: 'none' NumObservations: 94 NumTrained: 100 Method: 'LSBoost' LearnerNames: {'Tree'} ReasonForTermination: 'Terminated normally after completing the requested number of training cycles.' FitInfo: [100×1 double] FitInfoDescription: {2×1 cell} Regularization: []
Properties, Methods
Mdl
is a RegressionEnsemble
model object that contains the training data, among other things.
Create a compact version of Mdl
.
CMdl = CompactRegressionEnsemble PredictorNames: {'W' 'C'} ResponseName: 'Y' CategoricalPredictors: 2 ResponseTransform: 'none' NumTrained: 100
Properties, Methods
CMdl
is a CompactRegressionEnsemble
model object. CMdl
is almost the same as Mdl
. One exception is that CMdl
does not store the training data.
Compare the amounts of space consumed by Mdl
and CMdl
.
mdlInfo = whos('Mdl'); cMdlInfo = whos('CMdl'); [mdlInfo.bytes cMdlInfo.bytes]
Mdl
consumes more space than CMdl
.
CMdl.Trained
stores the trained regression trees (CompactRegressionTree
model objects) that compose Mdl
.
Display a graph of the first tree in the compact ensemble.
view(CMdl.Trained{1},'Mode','graph');
By default, fitrensemble
grows shallow trees for boosted ensembles of trees.
Predict the fuel economy of a typical car using the compact ensemble.
typicalX = [mean(X(:,1)) mode(X(:,2))]; predMeanX = predict(CMdl,typicalX)
Tips
For a compact ensemble of regression trees, the Trained
property of ens
stores a cell vector of ens.NumTrained
CompactRegressionTree model objects. For a textual or graphical display of tree t
in the cell vector, enter
Extended Capabilities
Usage notes and limitations:
- The predict function supports code generation.
- To integrate the prediction of an ensemble into Simulink®, you can use the RegressionEnsemble Predict block in the Statistics and Machine Learning Toolbox™ library or a MATLAB® Function block with the
predict
function. - When you train an ensemble by using fitrensemble, the following restrictions apply.
- The value of the ResponseTransform name-value argument cannot be an anonymous function.
- Code generation limitations for regression trees also apply to ensembles of regression trees. You cannot use surrogate splits; that is, the value of the Surrogate name-value argument must be
"off"
.
- For fixed-point code generation, the following additional restrictions apply.
- When you train an ensemble by using fitrensemble, the value of the ResponseTransform name-value argument must be
"none"
(default). - Categorical predictors (
logical
,categorical
,char
,string
, orcell
) are not supported. You cannot use theCategoricalPredictors
name-value argument. To include categorical predictors in a model, preprocess them by using dummyvar before fitting the model.
- When you train an ensemble by using fitrensemble, the value of the ResponseTransform name-value argument must be
For more information, see Introduction to Code Generation.
Usage notes and limitations:
- The following object functions fully support GPU arrays:
- The following object functions offer limited support for GPU arrays:
- The object functions execute on a GPU if at least one of the following applies:
- The model was fitted with GPU arrays.
- The predictor data that you pass to the object function is a GPU array.
- The response data that you pass to the object function is a GPU array.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2011a