svm_opt: Bayesian Optimization for SVM

Description Usage Arguments Value Examples

Description

This function estimates parameters for SVM(Gaussian Kernel) based on bayesian optimization

Usage

1
2
3
4
5
6
svm_opt(train_data, train_label, test_data, test_label,
  gamma_range = c(10^(-3), 10^1), cost_range = c(10^(-2), 10^2),
  svm_kernel = "radial", degree_range = c(3L, 10L),
  coef0_range = c(10^(-1), 10^1), init_points = 4, n_iter = 10,
  acq = "ei", kappa = 2.576, eps = 0, optkernel = list(type =
  "exponential", power = 2))

Arguments

train_data

A data frame for training of SVM

train_label

The column of class to classify in the training data

test_data

A data frame for training of SVM

test_label

The column of class to classify in the test data

gamma_range

The range of gamma. Default is c(10 ^ (-3), 10 ^ 1)

cost_range

The range of C(Cost). Default is c(10 ^ (-2), 10 ^ 2)

svm_kernel

Kernel used in SVM. You might consider changing some of the following parameters, depending on the kernel type.

  • linear: u'v

  • polynomial: (γ u'v +coef0)^{degree}

  • radial basis: exp(-γ|u-v|^2)

  • sigmoid: tanh(γ u'v + coef0)

degree_range

Parameter needed for kernel of type polynomial. Default is c(3L, 10L)

coef0_range

parameter needed for kernels of type polynomial and sigmoid. Default is c(10 ^ (-1), 10 ^ 1)

init_points

Number of randomly chosen points to sample the target function before Bayesian Optimization fitting the Gaussian Process.

n_iter

Total number of times the Bayesian Optimization is to repeated.

acq

Acquisition function type to be used. Can be "ucb", "ei" or "poi".

  • ucb GP Upper Confidence Bound

  • ei Expected Improvement

  • poi Probability of Improvement

kappa

tunable parameter kappa of GP Upper Confidence Bound, to balance exploitation against exploration, increasing kappa will make the optimized hyperparameters pursuing exploration.

eps

tunable parameter epsilon of Expected Improvement and Probability of Improvement, to balance exploitation against exploration, increasing epsilon will make the optimized hyperparameters are more spread out across the whole range.

optkernel

Kernel (aka correlation function) for the underlying Gaussian Process. This parameter should be a list that specifies the type of correlation function along with the smoothness parameter. Popular choices are square exponential (default) or matern 5/2

Value

The test accuracy and a list of Bayesian Optimization result is returned:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(MlBayesOpt)

set.seed(71)
res0 <- svm_opt(train_data = iris_train,
                train_label = Species,
                test_data = iris_test,
                test_label = Species,
                svm_kernel = "polynomial",
                init_points = 10,
                n_iter = 1)

MlBayesOpt documentation built on May 2, 2019, 9:20 a.m.