svm0: Classification by SVM

Description Usage Arguments Details Value Source Examples

View source: R/svm0.R

Description

Use different datasets to train SVM model in order to classify the test set.

Usage

1
2
3
4
5
svm0(yflag = F, train, test, yname)

svm1(yflag = F, traindata, testdata, ytrain, ytest)

svm2(yflag = F, traindata, train, testdata, test, yname)

Arguments

yflag

a flag that describes whether there is result-column in the test set.

train

a train set that needs to be transformed.

test

a test set that needs to be transformed.

yname

the name of result-column.

traindata

a dataset that the train set transforms into.

testdata

a dataset that the test set transforms into.

ytrain

the result-column of train set.

ytest

the result-column of test set.

Details

The function svm0 need original data to train SVM model. The function svm1 need transformed data to train SVM model. The function svm2 need transformed data augmented by original data to train SVM model. These functions train SVM model and predict classification result of test set.

Value

If there is result-column in test set, these functions give time of running, predicted result and the confusion matrix of actual and predicted class. Otherwise, these functions only give time and predicted result.

Source

For SVM, based on • Chang, Chih-Chung and Lin, Chih-Jen: LIBSVM: a library for Support Vector Machines http://www.csie.ntu.edu.tw/~cjlin/libsvm • Exact formulations of models, algorithms, etc. can be found in the document: Chang, Chih-Chung and Lin, Chih-Jen: LIBSVM: a library for Support Vector Machines http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.ps.gz • More implementation details and speed benchmarks can be found on: Rong-En Fan and Pai-Hsune Chen and Chih-Jen Lin: Working Set Selection Using the Second Order Information for Training SVM http://www.csie.ntu.edu.tw/~cjlin/papers/quadworkset.pdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
intest = subnum(rawdata, k = 10)[[1]]
test = rawdata[intest, ]
training = rawdata[-intest,]
groups = subgroup(training, 'class', c('attack', 'normal'))
d0 = groups[[1]]
d1 = groups[[2]]
train = groups[[3]]
data = trans(train, test, d0, d1, 'class', yflag=T)
traindata = data[[1]]
testdata = data[[2]]
svm0(yflag = T, train, test, 'class')
svm0(yflag = F, train, test[, -40], 'class')
svm1(yflag = T, traindata, testdata, ytrain = train[, 40], ytest = test[, 40])
svm1(yflag = F, traindata, testdata, ytrain = train[, 40])
svm2(yflag = T, traindata, train, testdata, test, 'class')
svm2(yflag = F, traindata, train, testdata, test[,-40],'class')

ShanLu92/FeaAug documentation built on Jan. 31, 2021, 7:21 p.m.