# NOT RUN {
library(TunePareto)
data(esl)
data = esl$data
labels = esl$labels
foldList = generateCVRuns(labels = labels,
ntimes = 2,
nfold = 2,
leaveOneOut = FALSE,
stratified = TRUE)
predMap = predictionMap(data, labels, foldList = foldList,
classifier = tunePareto.svm(), kernel='linear')
# generate Subcascades object
subc = subcascades(predMap,thresh=0.7)
#define sets
set1 = list(c(1,2,3),c(2,3,4))
set2 = c('1>2>3','2>3>4')
# filter for the subset cascades that contain either the classes
# {1,2,3} or {2,3,4} independent of the order, but neighbored
dropSets(subc, sets = set1, direction = 'sub',
ordered = FALSE, neighborhood = 'direct')
dropSets(subc, sets = set2, direction = 'sub',
ordered = FALSE, neighborhood = 'direct')
# filter for the superset cascades that contain either the classes
# {1,2,3} or {2,3,4} independent of the order, but neighbored
dropSets(subc, sets = set1, direction = 'super',
ordered = FALSE, neighborhood = 'direct')
dropSets(subc, sets = set2, direction = 'super',
ordered = FALSE, neighborhood = 'direct')
# filter for the superset cascades that contain both the classes
# {1,2,3} and {2,3,4} in exactly the given order, but allowing
# for other classes inbetween
dropSets(subc, sets = set1, direction = 'super',
ordered = TRUE, neighborhood = 'indirect', type = 'all')
dropSets(subc, sets = set2, direction = 'super',
ordered = TRUE, neighborhood = 'indirect', type = 'all')
# filter for the exact cascades
# sets can be a numeric list
result <- dropSets(subc, list(c(0,1,2),c(2,3,4,1)),
direction = 'exact', ordered=TRUE)
unlist(t(lapply(result,rownames)))
# or sets can be a character vector
result <- dropSets(subc, c('0>1>2','2>3>4>1'),
direction = 'exact',ordered=TRUE)
unlist(t(lapply(result,rownames)))
# }
Run the code above in your browser using DataLab