Main Content

compact

Reduce size of multiclass error-correcting output codes (ECOC) model

Description

example

CompactMdl= compact(Mdl)returns a compact multiclass error-correcting output codes (ECOC) model (CompactMdl), the compact version of the trained ECOC modelMdl.CompactMdlis aCompactClassificationECOCobject.

CompactMdldoes not contain the training data, whereasMdlcontains the training data in itsXandYproperties. Therefore, although you can predict class labels usingCompactMdl,你不能做助教ks such as cross-validation with the compact ECOC model.

Examples

collapse all

Reduce the size of a full ECOC model by removing the training data. Full ECOC models (ClassificationECOCmodels) hold the training data. To improve efficiency, use a smaller classifier.

Load Fisher's iris data set. Specify the predictor dataX, the response dataY, and the order of the classes inY.

loadfisheririsX = meas; Y = categorical(species); classOrder = unique(Y);

Train an ECOC model using SVM binary classifiers. Standardize the predictor data using an SVM templatet, and specify the order of the classes. During training, the software uses default values for empty options int.

t = templateSVM('Standardize',true); Mdl = fitcecoc(X,Y,'Learners',t,'ClassNames',classOrder);

Mdlis aClassificationECOCmodel.

Reduce the size of the ECOC model.

CompactMdl = compact(Mdl)
CompactMdl = CompactClassificationECOC ResponseName: 'Y' CategoricalPredictors: [] ClassNames: [setosa versicolor virginica] ScoreTransform: 'none' BinaryLearners: {3x1 cell} CodingMatrix: [3x3 double] Properties, Methods

CompactMdlis aCompactClassificationECOCmodel.CompactMdldoes not store all of the properties thatMdlstores. In particular, it does not store the training data.

Display the amount of memory each classifier uses.

whos('CompactMdl','Mdl')
Name Size Bytes Class Attributes CompactMdl 1x1 15116 classreg.learning.classif.CompactClassificationECOC Mdl 1x1 28357 ClassificationECOC

The full ECOC model (Mdl) is approximately double the size of the compact ECOC model (CompactMdl).

To label new observations efficiently, you can removeMdlfrom the MATLAB® Workspace, and then passCompactMdland new predictor values topredict.

Input Arguments

collapse all

Full, trained multiclass ECOC model, specified as aClassificationECOCmodel trained withfitcecoc.

Extended Capabilities

Version History

Introduced in R2014b