plotClassProbs

0th

Percentile

Plot Predicted Probabilities in Classification Models

This function takes an object (preferably from the function 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

Keywords
hplot
Usage
plotClassProbs(object,
               plotType = "histogram",
               useObjects = FALSE,
               ...)
Value

  • A lattice object. Note that the plot has to be printed to be displayed (especially in a loop).

Aliases
Examples
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))
Documentation reproduced from package caret, version 5.07-001, License: GPL-2

Community examples

Looks like there are no examples yet.