Learn R Programming

VRPM (version 1.2)

plotperf: Performance plots for the approximation of an SVM model.

Description

Generate performance plots for the approximation of an SVM model.

Usage

plotperf(mymodel, mydata, indy, mytestdata, type = "all", filename)

Arguments

mymodel

Element of class ksvm.

mydata

Data on which mymodel was trained on.

indy

Column number of the outcome in mydata.

mytestdata

Data on which to evaluate mymodel. (Optional)

type

Type of performance plot (c="all","lp","probs","outcomes","contributions", "ROC","corrplot"). See details for more information.

filename

Name of the resulting graph.

Details

Different types of plots are possible. When type="all", all the options are generated. When type="lp", the latent variables of the approximation and the original SVM model are plotted against eachother. When type="probs" the estimated probabilities of the approximation and the SVM model are plotted against eachother. When type="outcomes" a bubble plot indicating the agreement between the approximation and the SVM model is generated. When type="contributions", the range of the contributions within the approximation, the range of the rest term and the range of the latent variable of the SVM model are represented by means of boxplots. All of these are shifted to have a median equal to zero. When type="ROC", ROC curves for the approximation and the SVM model are plotted. When mytestdata is non-empty, ROC curves for the test set are also provided.

References

Van Belle V., Van Calster B., Suykens J.A.K., Van Huffel S. and Lisboa P., Explaining support vector machines: a color based nomogram, Internal Report 16-27, ESAT-Stadius, KU Leuven (Leuven, Belgium), 2016

Examples

Run this code
# NOT RUN {
#### Support Vector Machine classifier
library(kernlab)
data(iris)
levels(iris$Species)[levels(iris$Species)=="setosa"] <- "other"
levels(iris$Species)[levels(iris$Species)=="virginica"] <- "other"
names(iris)=c("SL","SW","PL","PW","Species")
# good model
model <-ksvm(Species ~ ., data = iris,prob.model=TRUE,kpar=list(0.03),C=10)
# bad model
model2 <-ksvm(Species ~ ., data = iris,prob.model=TRUE,kpar=list(10),C=10)
# plot latent variables of approximation and SVM
plotperf(model,iris,indy=5,type="lp",filename="iris")
plotperf(model2,iris,indy=5,type="lp",filename="iris2")
# plot contributions of approximation and SVM
# good model: rest term is small in comparison with other contributions and lpmodel 
# (latent variable of SVM)
plotperf(model,iris,indy=5,type="contributions",filename="iris") 
# bad model: rest term is large in comparison with other contributions and lpmodel 
# (latent variable of SVM)
plotperf(model2,iris,indy=5,type="contributions",filename="iris2")
# plot latent variables of approximation and SVM
plotperf(model,iris,indy=5,type="outcomes",filename="iris")
plotperf(model2,iris,indy=5,type="outcomes",filename="iris2")
# }

Run the code above in your browser using DataLab