nLinearCoeffs
Number of nonzero linear coefficients in discriminant analysis classifier
Description
Examples
Find the Number of Nonzero Coefficients in a Discriminant Analysis Classifier
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
Mdl
— Trained discriminant analysis classifier
ClassificationDiscriminant
model object | CompactClassificationDiscriminant
model object
Trained discriminant analysis classifier, specified as a ClassificationDiscriminant
model object trained with fitcdiscr
, or a CompactClassificationDiscriminant
model
object created with compact
.
delta
— Threshold
numeric scalar | numeric vector
Threshold, specified as a numeric scalar or numeric vector. See Gamma and Delta.
Example: delta = [1 2 3]
Data Types: single
| double
Output Arguments
ncoeffs
— Number of nonzero coefficients in discriminant analysis classifier
nonnegative integer
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
Gamma and Delta
Regularization is the process of finding a small set of predictors
that yield an effective predictive model. For linear discriminant
analysis, there are two parameters, γ and δ,
that control regularization as follows. cvshrink
helps
you select appropriate values of the parameters.
Let Σ represent the covariance matrix of the data X, and let be the centered data (the data X minus the mean by class). Define
The regularized covariance matrix is
Whenever γ ≥ MinGamma
, is nonsingular.
Let μk be the mean vector for those elements of X in class k, and let μ0 be the global mean vector (the mean of the rows of X). Let C be the correlation matrix of the data X, and let be the regularized correlation matrix:
where I is the identity matrix.
The linear term in the regularized discriminant analysis classifier for a data point x is
The parameter δ enters into this equation as a threshold on the final term in square brackets. Each component of the vector is set to zero if it is smaller in magnitude than the threshold δ. Therefore, for class k, if component j is thresholded to zero, component j of x does not enter into the evaluation of the posterior probability.
The DeltaPredictor
property is a vector related
to this threshold. When δ ≥ DeltaPredictor(i)
, all classes k have
Therefore, when δ ≥ DeltaPredictor(i)
, the regularized
classifier does not use predictor i
.
Version History
Introduced in R2011b
See Also
Classes
Functions
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)