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

svm_cv_opt(data, 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), n_folds,
  init_points = 4, n_iter = 10, acq = "ei", kappa = 2.576, eps = 0,
  optkernel = list(type = "exponential", power = 2))

Arguments

data

data

label

label for classification

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: \((\gamma u'v +coef0)^{degree}\)

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

  • sigmoid: \(tanh(\gamma 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)

n_folds

if a integer value k>0 is specified, a k-fold cross validation on the training data is performed to assess the quality of the model: the accuracy rate for classification and the Mean Squared Error for regression

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:

  • Best_Par a named vector of the best hyperparameter set found

  • Best_Value the value of metrics achieved by the best hyperparameter set

  • History a data.table of the bayesian optimization history

  • Pred a data.table with validation/cross-validation prediction for each round of bayesian optimization history

Examples

library(MlBayesOpt) set.seed(71) res0 <- svm_cv_opt(data = iris, label = Species, n_folds = 3, init_points = 10, n_iter = 1)
#> elapsed = 0.02 Round = 1 gamma_opt = 3.3299 cost_opt = 11.7670 Value = 0.9333 #> elapsed = 0.01 Round = 2 gamma_opt = 5.5515 cost_opt = 76.1740 Value = 0.9067 #> elapsed = 0.01 Round = 3 gamma_opt = 3.2744 cost_opt = 14.1882 Value = 0.9400 #> elapsed = 0.01 Round = 4 gamma_opt = 2.1175 cost_opt = 76.6932 Value = 0.9200 #> elapsed = 0.01 Round = 5 gamma_opt = 3.1619 cost_opt = 84.2154 Value = 0.9600 #> elapsed = 0.01 Round = 6 gamma_opt = 9.4727 cost_opt = 77.6772 Value = 0.8933 #> elapsed = 0.01 Round = 7 gamma_opt = 6.6175 cost_opt = 13.3914 Value = 0.9267 #> elapsed = 0.02 Round = 8 gamma_opt = 8.8943 cost_opt = 80.5955 Value = 0.8733 #> elapsed = 0.01 Round = 9 gamma_opt = 3.3808 cost_opt = 89.6793 Value = 0.9333 #> elapsed = 0.01 Round = 10 gamma_opt = 4.3481 cost_opt = 92.6987 Value = 0.9000 #> elapsed = 0.01 Round = 11 gamma_opt = 2.9508 cost_opt = 84.8600 Value = 0.9467 #> #> Best Parameters Found: #> Round = 5 gamma_opt = 3.1619 cost_opt = 84.2154 Value = 0.9600