ensemble: Ensemble Objects for Classification

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/Ensemble.R

Description

This function provides for the creation, and storage of an ensemble of simpler classifiers. Right now, only a single type of classifier is available; this shall be fixed in the future.

Usage

1
ensemble(dat, train, test, labs, bel.type = c('kde', 'knn', 'jit'), bel_options)

Arguments

dat

The full data matrix, including both test and train rows.

train

A vector containing the row numbers (or names) of the training data in the matrix dat.

test

A vector containing the row numbers (or names) of the test data in the matrix dat.

labs

Labels for the training data; must be of the same length as train.

bel.type

The type of belief function to build the Ensemble. For more details, see help on Belief.

bel_options

The options list that should be passed to the belief function.

Details

The simpler classifiers must work in 2-dimensions projections of the data.

Value

Returns a list of functions which can be used to query and / or manipulate the created ensemble object.

try.matrices

Takes a single argument n which is the number of matrices you want to try.

get.bpamats

Returns a list of bpa.mat objects representing the classifications recieved from each projection.

Author(s)

Mohit Dayal

See Also

belief

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
data(cancer)
table(cancer$V2)
colnames(cancer)[1:2] <- c('id', 'type')

cancer.d <- as.matrix(cancer[,3:32])
labs <- cancer$type
test_size <- floor(0.15*nrow(cancer.d))
train <- sample(1:nrow(cancer.d), size = nrow(cancer.d) - test_size)
test <- which(!(1:569 %in% train))
truelabs = labs[test]

e <- ensemble(dat = cancer.d, labs = labs[train], train = train, test =
test, bel.type = 'kde', bel_options = list(coef = 0.90))

##Try more matrices than that in real life!
##Also increase the mc.cores parameter if you have more cores!
e$try.matrices(n = 3, mc.cores = 1)

y <- e$get.bpamats()
length(y)

##Can see results from each projection
##b.1  <- bpamat(mat = y[[1]]$get.mat())
##b.2  <- bpamat(mat = y[[2]]$get.mat())
##b.12b <- combine.bpa.mat.bs(b.1, b.2)
##b.12d <- combine.bpa.mat.ds(b.1, b.2)
##b.12b$get.classify()
##b.12d$get.classify()

##All the results
##b.n <- lapply(y, function(x) x$get.classify())
##allb <- combine.bpa.mat.list.bs(e$get.bpamats())
##alld <- combine.bpa.mat.list.ds(e$get.bpamats())

##fn1 <- function(x)
##    table(truelabs, x$get.classify())

##fn2 <- function(x)
##    {
##        tmp <- table(truelabs, x$get.classify())
##        100 *sum(diag(tmp)) / sum(tmp)
##    }

##fn1(allb)
##fn2(allb)
##fn1(alld)
##fn2(alld)

Example output

Warning message:
no DISPLAY variable so Tk is not available 

  B   M 
357 212 
Warning messages:
1: In crossprod(x[, j], x[, i]) * x[, i] :
  Recycling array of length 1 in array-vector arithmetic is deprecated.
  Use c() or as.vector() instead.

2: In crossprod(x[, j], x[, i]) * x[, i] :
  Recycling array of length 1 in array-vector arithmetic is deprecated.
  Use c() or as.vector() instead.

3: In crossprod(x[, j], x[, i]) * x[, i] :
  Recycling array of length 1 in array-vector arithmetic is deprecated.
  Use c() or as.vector() instead.

4: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
5: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'. 
6: loading Rplot failed 
[1] 3

MuViCP documentation built on May 1, 2019, 7:56 p.m.