showClass("ConformalClassification")
# Optional for parallel training
#library(doMC)
#registerDoMC(cores=4)
data(LogS)
# convert data to categorical
LogSTrain[LogSTrain > -4] <- 1
LogSTrain[LogSTrain <= -4] <- 2
LogSTest[LogSTest > -4] <- 1
LogSTest[LogSTest <= -4] <- 2
LogSTrain <- factor(LogSTrain)
LogSTest <- factor(LogSTest)
# Remove part of the data to allow for quick training
LogSTrain <- LogSTrain[1:20]
LogSTest <- LogSTest[1:20]
LogSDescsTrain <- LogSDescsTrain[1:20,]
LogSDescsTest <- LogSDescsTest[1:20,]
algorithm <- "rf"
trControl <- trainControl(method = "cv", number=5,savePredictions=TRUE)
set.seed(3)
#number of trees
nb_trees <- 100
model <- train(LogSDescsTrain, LogSTrain,
algorithm,type="classification",
trControl=trControl,predict.all=TRUE,
keep.forest=TRUE,norm.votes=TRUE,
ntree=nb_trees)
# Instantiate the class and get the p.values
example <- ConformalClassification$new()
example$CalculateCVScores(model=model)
example$CalculatePValues(new.data=LogSDescsTest)
# we get the p.values:
example$p.values$P.values
# we get the significance of these p.values.
example$p.values$Significance_p.values
Run the code above in your browser using DataLab