Learn R Programming

superml (version 0.4.0)

SVMTrainer: Support Vector Machines Trainer

Description

Trains a support vector machine (svm) model. It is based on the magnificently fast speed liquidSVM R package. It provides a more unified interface over the package retaining all its functionality.

The model is intelligently trained with a default set of hyper parameters. Also, there are inbuilt grid setups which can be easily initialised. It has capability to support batch processing of data to avoid memory errors. It supports binary classification, multi classification, regression models

Usage

SVMTrainer

Format

R6Class object.

Usage

For usage details see Methods, Arguments and Examples sections.

svm = SVMTrainer$new(type=NULL,scale=TRUE, gammas=NULL, lambdas=NULL, c_values=NULL,
                     predict.prob=FALSE, verbose=NULL, ncores=NULL, partition_choice=0,
                     seed=-1, grid_choice=NULL, useCells=FALSE, mc_type=NULL,
                     adaptivity_control=0)
svm$fit(X_train, y_train)
prediction <- svm$predict(X_test)

Methods

$new()

Initialises an instance of svm model

$fit()

fits model to an input train data and trains the model.

$predict()

returns predictions by fitting the trained model on test data.

Arguments

params

for detailed explanation on parameters, refer to original documentation https://cran.r-project.org/web/packages/e1071/e1071.pdf

type

type of model to train, possible values: "bc" = binary classification, "mc" = multiclassification, "ls" = least square regression, "qt" = quantile regression

scale

normalises the feature between 0 and 1, default = TRUE

gammas

bandwidth of the kernel, default value is chosen from a list of gamma values generated internally

Examples

Run this code
# NOT RUN {
data(iris)
## Multiclassification
svm <- SVMTrainer$new()
svm$fit(iris, "Species")
p <- svm$predict(iris)

## Least Squares
svm <- SVMTrainer$new()
svm$fit(trees, "Height")
p <- svm$predict(trees)
# }

Run the code above in your browser using DataLab