Description Usage Arguments Details Value Author(s) Examples
Compute classification performance according to common evaluation metrics: classification error, AUC and log-loss.
1 | classLoss(actual, predicted, prob, eval.metric = "overall_error")
|
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
|
There are four evaluation metrics available sor far:
eval.metric="overal_error"
: default option. It gives the
overall misclassification rate. It do not require the prob
parameter.
eval.metric="mean_error"
: gives the mean per class
misclassification rate. It do not require the prob
parameter.
eval.metric="auc"
: gives the mean per class area under the ROC
curve. It requires the prob
parameter.
eval.metric="logloss"
: gives the cross-entropy or logarithmic
loss. It requires the prob
parameter.
The classification performance measure.
David Pinto.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.