Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

kfoldPredict

Class: ClassificationPartitionedModel

Predict response for observations not used for training

Syntax

label = kfoldPredict(obj)
[label,score] = kfoldPredict(obj)
[label,score,cost] = kfoldPredict(obj)

Description

label = kfoldPredict(obj) returns class labels predicted by obj, a cross-validated classification. For every fold, kfoldPredict predicts class labels for in-fold observations using a model trained on out-of-fold observations.

[label,score] = kfoldPredict(obj) returns the predicted classification scores for in-fold observations using a model trained on out-of-fold observations.

[label,score,cost] = kfoldPredict(obj) returns misclassification costs.

Output Arguments

label

Vector of class labels of the same type as the response data used in training obj. Each entry of label corresponds to a predicted class label for the corresponding row of X.

score

Numeric matrix of size N-by-K, where N is the number of observations (rows) in obj.X, and K is the number of classes (in obj.ClassNames). score(i,j) represents the confidence that row i of obj.X is of class j. For details, see Definitions.

cost

Numeric matrix of misclassification costs of size N-by-K. cost(i,j) is the average misclassification cost of predicting that row i of obj.X is of class j.

Examples

expand all

Find the cross-validation predictions for a model based on Fisher's iris data.

Load Fisher's iris data set.

load fisheriris

Train an ensemble of classification trees.

rng(1); % For reproducibility
Mdl = fitensemble(meas,species,'AdaBoostM2',100,'Tree');

Cross valdate the trained ensemble using 10-fold cross validation.

CVMdl = crossval(Mdl);

Estimate cross-validation predicted labels and scores.

[elabel,escore] = kfoldPredict(CVMdl);

Display the maximum and minimum scores of each class.

max(escore)
min(escore)
ans =

    9.3862    8.9871   10.1866


ans =

    0.0018    3.8359    0.9573

Definitions

expand all

Was this topic helpful?