Beruflich Dokumente
Kultur Dokumente
classify
Discriminant analysis
Syntax
class = classify(sample,training,group)
class = classify(sample,training,group,'type')
class = classify(sample,training,group,'type',prior)
[class,err] = classify(...)
[class,err,POSTERIOR] = classify(...)
[class,err,POSTERIOR,logp] = classify(...)
[class,err,POSTERIOR,logp,coeff] = classify(...)
Description
class = classify(sample,training,group)classifies each row of the data in
sampleinto one of the groups in training. sampleand trainingmust be matrices w ith
the same number of columns. groupis a grouping variable for training. Its unique values
define groups; each element defines the group to w hich the corresponding row of training
belongs. groupcan be a categorical variable, a numeric vector, a string array, or a cell array of
strings. trainingand groupmust have the same number of row s. classifytreats NaNs
or empty strings in groupas missing values, and ignores the corresponding row s of
training. The output classindicates the group to w hich each row of samplehas been
assigned, and is of the same type as group.
class = classify(sample,training,group,'type')allow s you to specify the
type of discriminant function. Specify typeinside single quotes. typeis one of:
linear Fits a multivariate normal density to each group, w ith a pooled estimate of
covariance. This is the default.
diaglinear Similar to linear, but w ith a diagonal covariance matrix estimate (naive
Bayes classifiers).
quadratic Fits multivariate normal densities w ith covariance estimates stratified by
group.
diagquadratic Similar to quadratic, but w ith a diagonal covariance matrix estimate
(naive Bayes classifiers).
mahalanobis Uses Mahalanobis distances w ith stratified covariance estimates.
class = classify(sample,training,group,'type',prior)allow s you to
specify prior probabilities for the groups. prioris one of:
A numeric vector the same length as the number of unique values in group(or the number
of levels defined for group, if groupis categorical). If groupis numeric or categorical, the
order of priormust correspond to the ordered values in group, or, if groupcontains
strings, to the order of first occurrence of the values in group.
A 1-by-1 structure w ith fields:
prob A numeric vector.
group Of the same type as group, containing unique values indicating the groups
to w hich the elements of probcorrespond.
As a structure, priorcan contain groups that do not appear in group. This can be useful
if trainingis a subset a larger training set. classifyignores any groups that appear in
the structure but not in the grouparray.
The string 'empirical', indicating that group prior probabilities should be estimated from
www.mathworks.in/help/stats/classify.html
1/4
3/22/13
Examples
For training data, use Fisher's sepal measurements for iris versicolor and virginica:
load fisheriris
SL = meas(51:end,1);
SW = meas(51:end,2);
group = species(51:end);
h1 = gscatter(SL,SW,group,'rb','v^',[],'off');
set(h1,'LineWidth',2)
legend('Fisher versicolor','Fisher virginica',...
'Location','NW')
www.mathworks.in/help/stats/classify.html
2/4
3/22/13
www.mathworks.in/help/stats/classify.html
3/4
3/22/13
More About
Grouping Variables
References
[1] Krzanow ski, W. J. Principles of Multivariate Analysis: A User's Perspective. New York:
Oxford University Press, 1988.
[2] Seber, G. A. F. Multivariate Observations. Hoboken, NJ: John Wiley & Sons, Inc., 1984.
See Also
classregtree| mahal| NaiveBayes
Yes
No
www.mathworks.in/help/stats/classify.html
4/4