Description Usage Arguments Value See Also Examples
Calculates classification error and Brier score measures
for evaluating a multi-class classifier output quality.
This function can be used in train()
function for
selecting the hyperparameter(s) of a classifier. This can be achieved by
specifying the argument metric
in train()
function call, and
summaryFunction = ceSummary
and classProbs = TRUE
in trainControl
.
See examples below.
1 |
data |
a data frame with columns |
lev |
a character vector of factors levels for the response. |
model |
a character string for the model name (as taken from the
|
... |
additional arguments to be passed to the low level functions. |
A vector containing the metrics.
twoClassSummary
, fscoreSummary
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | data = mlbench::mlbench.waveform(300)
data = data.frame(Class = data$classes, data$x)
data$Class = paste0("Class", data$Class)
describe(data)
mod1 = train(Class ~ . , data = data,
method = "rpart2",
tuneGrid = expand.grid(maxdepth = 1:10),
metric = "ClassError",
maximize = FALSE,
trControl = trainControl(method = "cv", number = 10,
classProbs = TRUE,
summaryFunction = ceSummary,
selectionFunction = "best") )
mod1
ggplot(mod1) +
scale_x_continuous(breaks = mod1$results$maxdepth) +
geom_errorbar(aes(ymin = with(mod1$results, ClassError - ClassErrorSD/sqrt(10)),
ymax = with(mod1$results, ClassError + ClassErrorSD/sqrt(10))),
width = 0.3)
mod2 = train(Class ~ . , data = data,
method = "rpart2",
tuneGrid = expand.grid(maxdepth = 1:10),
metric = "BrierScore",
maximize = FALSE,
trControl = trainControl(method = "cv", number = 10,
classProbs = TRUE,
summaryFunction = ceSummary,
selectionFunction = "best") )
mod2
ggplot(mod2) +
scale_x_continuous(breaks = mod2$results$maxdepth) +
geom_errorbar(aes(ymin = with(mod2$results, BrierScore - BrierScoreSD/sqrt(10)),
ymax = with(mod2$results, BrierScore + BrierScoreSD/sqrt(10))),
width = 0.3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.