classLoss: Classification Performance Measure

Description Usage Arguments Details Value Author(s) Examples

Description

Compute classification performance according to common evaluation metrics: classification error, AUC and log-loss.

Usage

1
classLoss(actual, predicted, prob, eval.metric = "overall_error")

Arguments

actual

factor array with the true class labels.

predicted

factor array with the predicted class labels.

prob

matrix with predicted class membership probabilities. Rows are observations and columns are classes. It is required to calculate AUC and log-loss.

eval.metric

evaluation metric to be used. It can be one of c("overall_error", "mean_error", "auc", "logloss"). The default option is "overall_error".

Details

There are four evaluation metrics available sor far:

Value

The classification performance measure.

Author(s)

David Pinto.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
library("mlbench")
library("caTools")
library("fastknn")

data("Ionosphere")

x <- data.matrix(subset(Ionosphere, select = -Class))
y <- Ionosphere$Class

set.seed(2048)
tr.idx <- which(sample.split(Y = y, SplitRatio = 0.7))
x.tr <- x[tr.idx,]
x.te <- x[-tr.idx,]
y.tr <- y[tr.idx]
y.te <- y[-tr.idx]

knn.out <- fastknn(xtr = x.tr, ytr = y.tr, xte = x.te, k = 10)

classLoss(actual = y.te, predicted = knn.out$class, eval.metric = "overall_error")
classLoss(actual = y.te, predicted = knn.out$class, prob = knn.out$prob, eval.metric = "logloss")

## End(Not run)

davpinto/fastknn documentation built on May 15, 2019, 1:18 a.m.