showClass("ConformalRegression")
#############################################
### Example
#############################################
## NOTE: the model built in this example has low predictive power as
## only little fraction of the training data set is used in order
## to make the example quick to run.
## Thus, the example merely intends to illustrate the code.
# Optional for parallel training
#library(doMC)
#registerDoMC(cores=4)
data(LogS)
# 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 <- "svmRadial"
tune.grid <- expand.grid(.sigma = expGrid(power.from=-10, power.to=-6, power.by=2, base=2),
.C = c(1,10,100))
trControl <- trainControl(method = "cv", number=5,savePredictions=TRUE)
set.seed(1)
model <- train(LogSDescsTrain, LogSTrain, algorithm,
tuneGrid=tune.grid,
trControl=trControl)
# Train an error model
error_model <- ErrorModel(PointPredictionModel=model,x.train=LogSDescsTrain,
savePredictions=TRUE,algorithm=algorithm,
trControl=trControl,
tune.grid=tune.grid)
# Instantiate the class and get the confidence intervals
example <- ConformalRegression$new()
example$CalculateAlphas(model=model,error_model=error_model,ConformityMeasure=StandardMeasure)
example$GetConfidenceIntervals(new.data=LogSDescsTest)
example$CorrelationPlot(obs=LogSTest)
example$plot
Run the code above in your browser using DataLab