classify: classify

Description Usage Arguments Value Author(s) Examples

Description

classifies data

Usage

1
classify(data, train, metric = "bayes")

Arguments

data

data to classify

train

training data

metric

bayes or mahal

Value

The classification matrix.

Author(s)

Jonathan Harrington

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## 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
  }

emuR documentation built on June 11, 2021, 5:10 p.m.