Package: classreg.learning.partition
Crossvalidated regression model
RegressionPartitionedModel
is a set of regression
models trained on crossvalidated 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
infold observations to predict response for outoffold 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
and
Y
with the first 1/5 excluded, the second model stored in
Trained{2}
was trained on X
and
Y
with the second 1/5 excluded, and so on. When you call
kfoldPredict
, 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 by
kfoldPredict
using the model trained
without this observation.
creates a crossvalidated regression model from a regression model
(CVMdl
=
crossval(Mdl
)Mdl
).
Alternatively:
CVGPRMdl = fitrgp(X,Y,Name,Value)
CVNetMdl = fitrnet(X,Y,Name,Value)
CVTreeMdl = fitrtree(X,Y,Name,Value)
Create a crossvalidated model when Name
is
'CrossVal'
, 'KFold'
,
'Holdout'
, 'Leaveout'
, or
'CVPartition'
. For syntax details, see fitrgp
, fitrnet
,
and fitrtree
.

A regression model, specified as one of the following:


Bin edges for numeric predictors, specified as a cell array of p numeric vectors, where p is the number of predictors. Each vector includes the bin edges for a numeric predictor. The element in the cell array for a categorical predictor is empty because the software does not bin categorical predictors. The software bins numeric predictors only if you specify the You can reproduce the binned predictor data X = mdl.X; % Predictor data
Xbinned = zeros(size(X));
edges = mdl.BinEdges;
% Find indices of binned predictors.
idxNumeric = find(~cellfun(@isempty,edges));
if iscolumn(idxNumeric)
idxNumeric = idxNumeric';
end
for j = idxNumeric
x = X(:,j);
% Convert x to array if x is a table.
if istable(x)
x = table2array(x);
end
% Group x into bins by using the Xbinned
contains the bin indices, ranging from 1 to the number of bins, for numeric predictors.
Xbinned values are 0 for categorical predictors. If
X contains NaN s, then the corresponding
Xbinned values are NaN s.


Categorical predictor indices, specified
as a vector of positive integers. Assuming that the predictor data contains
observations in rows, 

Name of the crossvalidated model, a character vector. 

Number of folds used in the crossvalidated model, a positive integer. 

Object holding parameters of 

Number of observations in the training data stored in


The partition of class 

A cell array of names for the predictor variables, in the order in which
they appear in 

Name of the response variable 

Function handle for transforming the raw response values (mean squared
error). The function handle should accept a matrix of response values and
return a matrix of the same size. The default character vector
Add or change a CVMdl.ResponseTransform = @function 

The trained learners, a cell array of compact regression models. 

The scaled 

A matrix or table of predictor values. 

A numeric column vector. Each entry in 
gather  Gather properties of Statistics and Machine Learning Toolbox object from GPU 
kfoldLoss  Loss for crossvalidated partitioned regression model 
kfoldPredict  Predict responses for observations in crossvalidated regression model 
kfoldfun  Crossvalidate function for regression 
Value. To learn how value classes affect copy operations, see Copying Objects.