Main Content

nLinearCoeffs

Number of nonzero linear coefficients in discriminant analysis classifier

Description

ncoeffs = nLinearCoeffs(Mdl) returns the number of nonzero linear coefficients in the linear discriminant analysis classifier Mdl.

example

ncoeffs = nLinearCoeffs(Mdl,delta) returns the number of nonzero linear coefficients for the threshold parameter delta.

Examples

collapse all

Find the number of nonzero coefficients in a discriminant analysis classifier for various Delta values.

Create a discriminant analysis classifier from the fishseriris data.

load fisheriris
obj = fitcdiscr(meas,species);

Find the number of nonzero coefficients in obj.

ncoeffs = nLinearCoeffs(obj)
ncoeffs = 
4

Find the number of nonzero coefficients for delta = 1, 2, 4, and 8.

delta = [1 2 4 8];
ncoeffs = nLinearCoeffs(obj,delta)
ncoeffs = 4×1

     4
     4
     3
     0

The DeltaPredictor property gives the values of delta where the number of nonzero coefficients changes.

ncoeffs2 = nLinearCoeffs(obj,obj.DeltaPredictor)
ncoeffs2 = 4×1

     4
     3
     1
     2

Input Arguments

collapse all

Trained discriminant analysis classifier, specified as a ClassificationDiscriminant model object trained with fitcdiscr, or a CompactClassificationDiscriminant model object created with compact.

Threshold, specified as a numeric scalar or numeric vector. See Gamma and Delta.

Example: delta = [1 2 3]

Data Types: single | double

Output Arguments

collapse all

Number of nonzero coefficients in the discriminant analysis classifier Mdl, returned as a nonnegative integer.

If you call nLinearCoeffs with the delta argument, ncoeffs is the number of nonzero linear coefficients for the threshold parameter delta. If delta is a vector, ncoeffs is a vector with the same number of elements.

If Mdl is a quadratic discriminant analysis classifier, ncoeffs is the number of predictors in Mdl.

More About

collapse all

Version History

Introduced in R2011b