Learn R Programming

emuR (version 2.5.0)

mahal: Classify using Mahalanobis distance

Description

Classifies using Mahalanobis distance

Usage

mahal(data, train)

Value

A label vector with one element per row of data

Arguments

data

A vector or matrix of data

train

A Gaussian model generated by train.

Details

The model argument contains the mean and inverse covariance matrix (or standard deviation if the data is one-dimensional) for each class in the training set as well as the class labels. This function calculates the Mahalanobis distance of each row of data from each class mean and assigns the label of the closest mean to that row. The result is a vector of labels corresponding to the rows of data.

The Mahalanobis distance between a data point and a class is the Euclidean distance between the point and the class mean divided by the covariance matrix for the class. This means that classes with large covariances will attract data points from a larger area than those with small covariances.

References

O'Shaughnessy, D. Speech Communication (Addison-Wesley: Reading, MA. 1987)

See Also

train