chooseClassifier: Choose The Best Classifier

Description Usage Arguments Note Examples

View source: R/chooseClassifier.R

Description

For an object of class formula and a data set the

chooseClassifier computes a ggplot showing the Area Under the Curve (result of performance) for classification algorithms like naiveBayes, lda, logistic regression glm with logit or probit link function. Also there is shown precision for every classifier on a ggplot. Any classifier can be added if needed. Contact: https://github.com/sandersone/twd1/issues.

Usage

1
chooseClassifier(formula, train, test, choice = c(1, 1, 1, 0, 0, 0, 0, 0))

Arguments

formula

A formula for classifiers to compute.

train

A data.frame denoting the training set.

test

A data.frame denoting the test set.

choice

A vecoter of length 8 specifying which classifiers should be compared. The order is as follows: Naive Bayes, LDA, Logit, Probit, SVM, Classification Tree, Boosting, Bagging. The default is c(1,1,1,0,0,0,0,0) which corresponds to Naive Bayes, LDA and Logit classifiers.

Note

For naive Bayes a parameter laplace is set to 0.2. For SVM parameters are type='C' and kernel="radial".

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
library(foreign)
se <- read.arff("http://archive.ics.uci.edu/ml/machine-learning-databases/00266/seismic-bumps.arff")
index <- 1:(2*nrow(se)/3)
se <- se[,-c(14:16)]
se_wyb <- se[,-c(9,15)]
train <- se_wyb[ index, ]
test <- se_wyb[ -index, ]
chooseClassifier( class~., train, test, rep(1,8) )

###################
chooseClassifier( class~., train, test, c(1,0,1,0,1,0,1,0) )

################
lo <- read.table("http://www.ipipan.eu/~teisseyrep/TEACHING/DM/DANE/brach3-5klas.txt",
header=TRUE)
lo[, 7] <- ifelse(lo[, 7] %in% c(1,2),1,0 )
index <- sample(1:nrow(lo), size=1/2*nrow(lo))
train <- lo[index,]
test <- lo[-index,]
lo[, 7] <- as.integer(lo[, 7])

chooseClassifier( LOC~., train, test, c(1,0,1,0,0,0,0,0) )


###############
fit <- read.table("http://www.ipipan.eu/~teisseyrep/TEACHING/DM/DANE/fitness.txt",
header = TRUE)

fit[, 8] <- sample(0:1, size = nrow(fit), replace=TRUE)
names(fit)[8] <- "group"
index <- sample(1:nrow(fit), size=1/2*nrow(fit))
train <- fit[index,]
test <- fit[-index,]

chooseClassifier( group~., train, test,
                  sample(0:1, size = 8, replace=TRUE) )

sandersone/twd1 documentation built on May 29, 2019, 1:45 p.m.