RegressionPartitionedModel - Cross-validated regression model - MATLAB (original) (raw)
Cross-validated regression model
Description
RegressionPartitionedModel
is a set of regression models trained on cross-validated folds. Estimate the quality of regression by cross validation using one or more “kfold” methods: kfoldPredict, kfoldLoss, and kfoldfun. Every “kfold” method uses models trained on in-fold observations to predict response for out-of-fold observations. For example, suppose you cross validate using five folds. In this case, every training fold contains roughly 4/5 of the data and every test fold contains roughly 1/5 of the data. The first model stored in Trained{1}
was trained on X
andY
with the first 1/5 excluded, the second model stored inTrained{2}
was trained on X
andY
with the second 1/5 excluded, and so on. When you callkfoldPredict, it computes predictions for the first 1/5 of the data using the first model, for the second 1/5 of data using the second model and so on. In short, response for every observation is computed bykfoldPredict using the model trained without this observation.
Creation
Description
You can create a RegressionPartitionedModel
object in two ways:
- Create a cross-validated model from a regression tree model objectRegressionTree by using thecrossval object function.
- Create a cross-validated model by using the fitrtree function and specifying one of the name-value arguments
CrossVal
,CVPartition
,Holdout
,KFold
, orLeaveout
.
Properties
This property is read-only.
Data Types: cell
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.
Name of the cross-validated model, returned as a character vector.
Data Types: char
Parameters of the cross-validated model, returned as an object.
This property is read-only.
Number of observations in the training data, returned as a positive integer.NumObservations
can be less than the number of rows of input data when there are missing values in the input data or response data.
Data Types: double
This property is read-only.
Partition used in cross-validation, returned as a CVPartition
object.
This property is read-only.
Predictor names in order of their appearance in the predictor dataX
, specified as a cell array of character vectors. The length ofPredictorNames
is equal to the number of columns in X
.
Data Types: cell
Response variable name, specified as a character vector.
Data Types: char
Function for transforming the raw response values (mean squared error), specified as a function handle or 'none'
. The default 'none'
means no transformation; equivalently, 'none'
means @(x)x
. A function handle must accept a matrix of response values and return a matrix of the same size.
Add or change a ResponseTransform
function using dot notation:
tree.ResponseTransform = @function
Data Types: char
| function_handle
Trained learners, returned as a cell array of compact regression models.
Data Types: cell
This property is read-only.
Scaled weights in the ensemble, returned as a numeric vector. W
has length n
, the number of rows in the training data. The sum of the elements of W
is 1
.
Data Types: double
This property is read-only.
Predictor values, returned as a real matrix or table. Each column ofX
represents one variable (predictor), and each row represents one observation.
Data Types: double
| table
This property is read-only.
Class labels corresponding to the observations in X
, returned as a categorical array, cell array of character vectors, character array, logical vector, or numeric vector. Each row of Y
represents the classification of the corresponding row of X
.
Data Types: single
| double
| logical
| char
| string
| cell
| categorical
Object Functions
gather | Gather properties of Statistics and Machine Learning Toolbox object from GPU |
---|---|
kfoldLoss | Loss for cross-validated partitioned regression model |
kfoldPredict | Predict responses for observations in cross-validated regression model |
kfoldfun | Cross-validate function for regression |
Examples
Load the sample data. Create a variable X
containing the Horsepower
and Weight
data.
load carsmall X = [Horsepower Weight];
Construct a regression tree using the sample data.
cvtree = fitrtree(X,MPG,'crossval','on');
Evaluate the cross-validation error of the carsmall
data using Horsepower
and Weight
as predictor variables for mileage (MPG
).
Extended Capabilities
Usage notes and limitations:
RegressionPartitionedModel
can be a cross-validated regression tree trained by using fitrtree with GPU array input arguments.- The object functions of a
RegressionPartitionedModel
model fully support GPU arrays.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2011a