extractProb
)
and creates a lattice plot.
If the call to extractProb
included test data, these data are shown, but
if unknowns were also included, these are not plotted
plotClassProbs(object, plotType = "histogram", useObjects = FALSE, ...)
extractProb
. There
should be columns for each level of the class factor and columns named obs
, pred
, model
(e.g. "rpart", "nnet" etc),
dataType
(e.g. "Training", "Test" etc) and optionally objects
(for giving names to objects with the same model type).histogram
or densityplot
## Not run:
# data(mdrr)
# set.seed(90)
# inTrain <- createDataPartition(mdrrClass, p = .5)[[1]]
#
# trainData <- mdrrDescr[inTrain,1:20]
# testData <- mdrrDescr[-inTrain,1:20]
#
# trainY <- mdrrClass[inTrain]
# testY <- mdrrClass[-inTrain]
#
# ctrl <- trainControl(method = "cv")
#
# nbFit1 <- train(trainData, trainY, "nb",
# trControl = ctrl,
# tuneGrid = data.frame(usekernel = TRUE, fL = 0))
#
# nbFit2 <- train(trainData, trainY, "nb",
# trControl = ctrl,
# tuneGrid = data.frame(usekernel = FALSE, fL = 0))
#
#
# models <- list(para = nbFit2, nonpara = nbFit1)
#
# predProbs <- extractProb(models, testX = testData, testY = testY)
#
# plotClassProbs(predProbs, useObjects = TRUE)
# plotClassProbs(predProbs,
# subset = object == "para" & dataType == "Test")
# plotClassProbs(predProbs,
# useObjects = TRUE,
# plotType = "densityplot",
# auto.key = list(columns = 2))
# ## End(Not run)
Run the code above in your browser using DataLab