RegressionPartitionedModel
statistics: RegressionPartitionedModel
Create a RegressionPartitionedModel object, a regression model
cross validated over a partition of its training data.
obj = RegressionPartitionedModel (Mdl, Partition)
refits Mdl once per fold of Partition, each time on the
observations that fold holds out of its test set, and stores the compact
form of every fit in Trained. It is normally reached through
crossval (Mdl) rather than called directly.
RegressionGAM, a
RegressionNeuralNetwork, or a RegressionSVM object.
cvpartition object over as many
observations as Mdl was trained on.
Every observation is held out by exactly one fold under -fold or
leave-one-out partitioning, so kfoldPredict can answer for it with a
model that never saw it. Under a holdout partition only the test set is
answered for, and the rest come back NaN.
See also: crossval, cvpartition, RegressionGAM, RegressionNeuralNetwork, RegressionSVM
Source Code: RegressionPartitionedModel
The RegressionPartitionedModel class contains the following properties:
A function handle, carried over from the model that was cross validated. This property is read-only.
A character vector holding the short name of the learner that was
cross validated, as MATLAB reports it: 'GAM', 'GP',
'NeuralNetwork' or 'SVM'. It is not the class name of
that learner, and the classification side uses the same names. This
property is read-only.
A cell array of character vectors. This property is read-only.
A numeric vector of column indices, and empty when none is. This property is read-only.
A character vector. This property is read-only.
A positive integer scalar. This property is read-only.
A numeric matrix holding the observations the model was trained on, the rows carrying missing values already removed. This property is read-only.
A numeric column vector with one entry per row of X. This
property is read-only.
A numeric column vector with one entry per observation. This property is read-only.
A structure holding the parameters the folds were fitted with, carried
through from the learner that was cross validated, beside
NLearn, the number of folds, and the Version,
Method and Type tags of this class. The
learner’s own tags are replaced rather than kept, so a cross-validated
SVM reports Method as 'PartitionedModel' and not
'SVM'.
Deviation from MATLAB. MATLAB reports the parameter record of
the cross-validation ensemble here rather than of the learner,
so it says nothing at all about how the folds were fitted: of its
eighteen fields only the fold count, its partitioner and a fit template
carry anything, and the rest are boosting settings left inert. Nor can
the parameters be reached through the folds, a compact model carrying
none in MATLAB. This class reports the fit instead, which is strictly
more than MATLAB offers, and everything MATLAB’s record does carry is
published here as the KFold, Partition, X,
Y, W and CrossValidatedModel properties.
This property is read-only.
A cell array with one compact model per fold, each fitted on the observations its fold holds out of the test set. This property is read-only.
A positive integer scalar. This property is read-only.
A cvpartition object. This property is read-only.
A cell array with one entry per predictor, holding that predictor’s bin edges where the learner discretized it before fitting. It is carried over from the model that was cross validated, and is empty whenever that model did no binning, which is every learner this package implements: MATLAB fills it only for its generalized additive model, which bins because it is built from boosted trees where ours is built from splines.
This property is read-only.
A logical scalar for a generalized additive model backing, taken from the model that was cross validated, and empty for every other backing.
MATLAB carries this on RegressionPartitionedGAM, one of five
per-learner partitioned classes this package deliberately does not have
(see crossval). With one class serving every backing the
property has to be declared for all of them, so it is empty where it
does not apply. It is placed last rather than first, where MATLAB’s
subclass shows it, because that subclass also moves
ResponseTransform to the end and no single order can match both
of MATLAB’s classes; matching the general one and appending is the only
coherent choice.
This property is read-only.
A scalar structure with fields PredictorTrees and
InteractionTrees, each a row with one entry per fold, for a
generalized additive model backing, and empty for every other.
It reports what each fold actually fitted, which the budget in
ModelParameters does not: a phase stops early when it can no
longer improve the fit, and the folds need not stop at the same place.
MATLAB carries this on its per-learner partitioned GAM classes, which
this package deliberately does not have (see crossval), so like
IsStandardDeviationFit it is declared here for every backing
and left empty where it does not apply.
This property is read-only.
The RegressionPartitionedModel class offers the following public methods:
RegressionPartitionedModel: obj = RegressionPartitionedModel (Mdl, Partition)
See the class documentation for what it holds and how it is reached.
See also: crossval, RegressionPartitionedModel
RegressionPartitionedModel: yFit = kfoldPredict (obj)
RegressionPartitionedModel: [yFit, ySD, yInt] = kfoldPredict (obj)
RegressionPartitionedModel: […] = kfoldPredict (…, 'Alpha', alpha)
yFit = kfoldPredict (obj) returns a column vector
with one entry per observation, each predicted by the fold’s model that
did not see it during training. An observation no fold tests, which a
holdout partition leaves outside its test set, comes back NaN.
RegressionPartitionedModel class object.
[yFit, ySD, yInt] = kfoldPredict (obj)
also returns the standard deviation ySD of each predicted
response and the two-column matrix yInt of prediction intervals,
each answered for by the fold that held the observation out. A
RegressionGP backing is the only one that fits the uncertainty
its predictions carry, so any other raises here. An untested
observation is NaN in all three.
[…] = kfoldPredict (…,
sets the significance level of the prediction intervals, which default
to 95 per cent at an alpha of 0.05.
'Alpha', alpha)
ySD does not follow ResponseTransform and the other two
outputs do, the same rule RegressionGP.predict applies: a
predicted response and an interval endpoint are on the response scale
and a standard deviation is not.
See also: RegressionPartitionedModel, kfoldLoss
RegressionPartitionedModel: L = kfoldLoss (obj)
RegressionPartitionedModel: L = kfoldLoss (…, name, value)
L = kfoldLoss (obj) returns the weighted mean
squared error between the response and the out-of-fold predictions of
kfoldPredict, over every observation some fold tests.
RegressionPartitionedModel class object.
L = kfoldLoss (…, name, value) accepts
the following Name-Value pairs.
| Name | Value |
|---|---|
'LossFun' | 'mse', the default,
'epsiloninsensitive', or a function handle called as
lossfun (Y, yFit, W) returning a scalar.
The -insensitive loss belongs to a support vector model
and is refused for any other, there being no tube to measure against. |
'Mode' | 'average', the default, which returns
one number over the observations of every fold asked for, or
'individual', which returns one number per fold. |
'Folds' | A vector of fold indices to restrict the loss to. It defaults to every fold. |
See also: RegressionPartitionedModel, kfoldPredict
RegressionPartitionedModel: vals = kfoldfun (obj, fun)
vals = kfoldfun (obj, fun) calls fun once
per fold and returns a numeric matrix whose row is
what fun returned for fold .
fun is a function handle taking seven inputs and returning a numeric vector of the same length every time it is called:
testvals = fun (M, Xtrain, Ytrain, Wtrain, …
Xtest, Ytest, Wtest)
|
M is the model the fold was fitted with, taken from
obj.Trained{k}; Xtrain, Ytrain and
Wtrain are the predictors, response and weights of the
observations that fold was trained on, and Xtest, Ytest and
Wtest those of the observations it held out.
See also: RegressionPartitionedModel, kfoldPredict, kfoldLoss