svm: Convenience function to initialize, train, select, and...

Description Usage Arguments Details Value See Also Examples

View source: R/liquidSVM.R

Description

The model is inited using the features and labels provided and training and selection is performed. If the labels are given as a factor classification is performed else least squares regression. If testing data is provided then this is used to calculate predictions and if test labels are provided also the test error and both are saved in $last_result of the returned svm object.

Usage

1
2
3
svm(x, y, ..., do.select = TRUE, testdata = NULL,
  testdata_labels = NULL, scenario = NULL, d = NULL, scale = TRUE,
  predict.prob = FALSE)

Arguments

x

either a formula or the features

y

either the data or the labels corresponding to the features x. It can be a character in which case the data is loaded using liquidData. If it is of type liquidData then after training and selection the model is tested using the testing data (y$test).

...

configuration parameters, see Configuration. Can be threads=2, display=1, gpus=1, etc.

do.select

can be set to a list to args to be passed to the select phase

testdata

if supplied then also testing is performed. If this is NULL but y is of type liquidData then y$test is used.

testdata_labels

the labels used if testing is also perfomed.

scenario

configures the model for a learning scenario: E.g. scenario='ls', scenario='mc', scenario='npl', scenario='qt' etc. Unlike the specialized functions qtSVM, exSVM, nplSVM etc. this does not trigger the correct select

d

level of display information

scale

if TRUE scales the features in the internal representation to values between 0 and 1.

predict.prob

If TRUE then a LS-svm will be trained and the conditional probabilities for the binary classification problems will be estimated. This also restricts the choices of mc_type to c("OvA_ls","AvA_ls").

Details

The training data can either be provided using a formula and a corresponding data.frame or the features and the labels are given directly.

svm has one more difference to lsSVM and mcSVM because it uses scale=TRUE by default and the others do not.

Value

an object of type svm. Depending on the usage this object has also $train_errors, $select_errors, and $last_result properties.

See Also

lsSVM, mcSVM, init.liquidSVM, trainSVMs, selectSVMs

Examples

1
2
3
4
5
6
7
8
9
# since Species is a factor the following performs multiclass classification
modelIris <- svm(Species ~ ., iris)
# equivalently
modelIris <- svm(iris[,1:4], iris$Species)

# since Height is numeric the following performs least-squares regression
modelTrees <- svm(Height ~ Girth + Volume, trees)
# equivalently
modelTrees <- svm(trees[,c(1,3)],trees$Height)

Example output

sh: 1: grep: Permission denied
sh: 1: /bin/cat: Permission denied
sh: 1: grep: Permission denied
sh: 1: /bin/cat: Permission denied
Warning message:
In (function (model, command.args = NULL, ..., d = NULL, warn.suboptimal = getOption("liquidSVM.warn.suboptimal",  :
  Solution may not be optimal: try training again using max_gamma=25
Warning message:
In (function (model, command.args = NULL, ..., d = NULL, warn.suboptimal = getOption("liquidSVM.warn.suboptimal",  :
  Solution may not be optimal: try training again using max_gamma=25

liquidSVM documentation built on Sept. 15, 2019, 1:02 a.m.