# CompactClassificationDiscriminant

Package: classreg.learning.classif

Compact discriminant analysis class

## Description

A CompactClassificationDiscriminant object is a compact version of a discriminant analysis classifier. The compact version does not include the data for training the classifier. Therefore, you cannot perform some tasks with a compact classifier, such as cross validation. Use a compact classifier for making predictions (classifications) of new data.

## Construction

cobj = compact(obj) constructs a compact classifier from a full classifier.

cobj = makecdiscr(Mu,Sigma) constructs a compact discriminant analysis classifier from the class means Mu and covariance matrix Sigma. For syntax details, see makecdiscr.

### Input Arguments

 obj Discriminant analysis classifier, created using fitcdiscr.

## Object Functions

 edge Classification edge logp Log unconditional probability density for discriminant analysis classifier loss Classification error mahal Mahalanobis distance to class means margin Classification margins nLinearCoeffs Number of nonzero linear coefficients partialDependence Compute partial dependence plotPartialDependence Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots predict Predict labels using discriminant analysis classification model

## Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects.

## Examples

collapse all

Construct a discriminant analysis classifier for the sample data.

fullobj = fitcdiscr(meas,species);

Construct a compact discriminant analysis classifier, and compare its size to that of the full classifier.

cobj = compact(fullobj);
b = whos('fullobj'); % b.bytes = size of fullobj
c = whos('cobj'); % c.bytes = size of cobj
[b.bytes c.bytes] % shows cobj uses 60% of the memory
ans = 1×2

18291       11678

The compact classifier is smaller than the full classifier.

Construct a compact discriminant analysis classifier from the means and covariances of the Fisher iris data.

mu(1,:) = mean(meas(1:50,:));
mu(2,:) = mean(meas(51:100,:));
mu(3,:) = mean(meas(101:150,:));

mm1 = repmat(mu(1,:),50,1);
mm2 = repmat(mu(2,:),50,1);
mm3 = repmat(mu(3,:),50,1);
cc = meas;
cc(1:50,:) = cc(1:50,:) - mm1;
cc(51:100,:) = cc(51:100,:) - mm2;
cc(101:150,:) = cc(101:150,:) - mm3;
sigstar = cc' * cc / 147;
cpct = makecdiscr(mu,sigstar,...
'ClassNames',{'setosa','versicolor','virginica'});

expand all