Statistics Toolbox | ![]() ![]() |
Syntax
class = classify(sample,training,group)
Description
assigns each row of the data in class = classify
(sample,training,group
)
sample
to one of the groups into which the training set, training
, is already divided. sample
and training
must have the same number of columns.
The vector group
contains integers, from one to the number of groups, that identify the group to which each row of the training set belongs. group
and training
must have the same number of rows.
The function returns class
, a vector with the same number of rows as sample
. Each element of class
identifies the group to which the corresponding element of sample
has been assigned. The classify
function determines the group into which each row in sample
is classified by computing the Mahalanobis distance between each row in sample
and each row in training
.
Example
load discrim sample = ratings(idx,:); training = ratings(1:200,:); g = group(1:200); class = classify(sample,training,g); first5 = class(1:5) first5 = 2 2 2 2 2
See Also
mahal
![]() | chi2stat | cluster | ![]() |