Predict responses using ensemble of regression models
Predictor data used to generate responses, specified as a numeric matrix or table.
Each row of
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
Indices of weak learners in the ensemble ranging from
A logical matrix of size
A numeric column vector with the same number of rows as
Find the predicted mileage for a car based on regression ensemble trained on the
carsmall data set and select the number of cylinders, engine displacement, horsepower, and vehicle weight as predictors.
load carsmall X = [Cylinders Displacement Horsepower Weight];
Train an ensemble of regression trees and predict
MPG for a four-cylinder car, with 200 cubic inch engine displacement, 150 horsepower, weighing 3000 lbs.
rens = fitrensemble(X,MPG); Mileage = predict(rens,[4 200 150 3000])
Mileage = 25.6467
This function fully supports tall arrays. For more information, see Tall Arrays.
Usage notes and limitations:
codegen (MATLAB Coder) to generate code for the
predict function. Save
a trained model by using
saveLearnerForCoder. Define an entry-point function
that loads the saved model by using
loadLearnerForCoder and calls the
predict function. Then use
to generate code for the entry-point function.
To generate single-precision C/C++ code for predict, specify the name-value argument
'DataType','single' when you call the
You can also generate fixed-point C/C++ code for
predict. Fixed-point code generation requires an additional step that
defines the fixed-point data types of the variables required for prediction. Create a
fixed-point data type structure by using the data type function
generateLearnerDataTypeFcn, and use the structure as an input argument of
loadLearnerForCoder in an entry-point function. Generating fixed-point
C/C++ code requires MATLAB
Coder™ and Fixed-Point Designer™.
Generating fixed-point code for
propagating data types for individual learners and, therefore, can be time
This table contains
notes about the arguments of
predict. Arguments not included in this
table are fully supported.
|Argument||Notes and Limitations|
For the usage notes and limitations of the model object,
Code Generation of the
|Name-value pair arguments||
Names in name-value pair arguments must be compile-time constants. For example, to allow user-defined indices up to 5 weak learners in the generated
For fixed-point code generation, the
For more information, see Introduction to Code Generation.