classify | R Documentation |
classifies data
classify(data, train, metric = "bayes")
data |
data to classify |
train |
training data |
metric |
bayes or mahal |
The classification matrix.
Jonathan Harrington
## The function is currently defined as
function (data, train, metric = "bayes")
{
probs <- distance(data, train, metric = metric)
if (metric == "bayes") {
best <- apply(probs, 1, max)
}
else if (metric == "mahal") {
best <- apply(probs, 1, min)
}
result <- rep("", length(best))
for (lab in 1:length(train$label)) {
tmp <- probs[, lab] == best
result[tmp] <- train$label[lab]
}
result
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.