svrHybrid: SVR with Metaheuristic Algorithms Optimization

View source: R/hybridSVR.R

svrHybridR Documentation

SVR with Metaheuristic Algorithms Optimization

Description

Trains a Support vector Regression Model by optimizing its parameter (Cost, Gamma, and Epsilon) using Metaheuristic Algorithms such as: Archimedes Optimization (AO), Coot Bird Optimization (CBO), Combined Archimedes Optimization with Coot Bird Optimization (AOCBO), Harris Hawks Optimization (HHO), Grey Wolf Optimizer (GWO), Ant Lion Optimization (ALO), and Enhanced Harris Hawks Optimization with Coot Bird Optimization (EHHOCBO).

Usage

svrHybrid(
  x_train,
  y_train,
  x_test,
  y_test,
  kernel = "radial",
  optimizer = "AO",
  objective = "RMSE",
  is.y.normalize = FALSE,
  min.y = min.y,
  max.y = max.y,
  max_iter = 100,
  N = 30,
  seed = 123,
  degree = 3,
  coef0 = 0,
  nu = 0.5,
  class.weights = NULL,
  cachesize = 40,
  tolerance = 0.001,
  scale = TRUE,
  shrinking = TRUE,
  cross = 0,
  probability = FALSE,
  fitted = TRUE,
  subset,
  na.action = na.omit
)

Arguments

x_train

A matrix or data frame contain predictors variable for training the model.

y_train

A numeric vector of target values for training model.

x_test

A matrix or data frame contain predictors variable for testing the model. It can be replaced by data validation to get the parameter if you separated the data as three categories and need more reliable model.

y_test

A numeric vector of target values for training model. It can be replaced by data validation to get the parameter if you separated the data as three categories and need more reliable model.

kernel

SVR kernel type used for modelling. Options: "linear", "radial", "polynomial", or "sigmoid". Default is radial.

optimizer

Metaheuristic Algorithms selection, options: "AO", "CBO", "AOCBO", "HHO", "GWO", "ALO", or "EHHOCBO". Default is AO.

objective

Objective function used for optimization as prediction quality measures. Options: "SMAPE", "MAPE", "RMSE", or "MAE". Default is RMSE.

is.y.normalize

Logical; use when prediction of target variable 'y' is on min-max scalling normalization. Default is FALSE. Note: It is only use when the data normalize by normalize() function in this package.

min.y

Minimum value of target (used for denormalization). No need to fill this parameter if y is not normalize.

max.y

Maximum value of target (used for denormalization). No need to fill this parameter if y is not normalize.

max_iter

Maximum number of iterations for the optimizer. Default is 100.

N

Population size for the optimizer. Default is 30.

seed

Random seed for reproducibility algorithm. Default is 123.

degree

Degree parameter for polynomial kernel.Default is 3.

coef0

Coefficient parameter used in polynomial/sigmoid kernels.

nu

Parameter for 'nu-regression' to controlling max proportion of error training and minimum proportion of support vectors. Default is 0.5, range: 0.1-0.9. Only use if the type of regression choosen is 'nu-regression'.

class.weights

A named list of class weights.

cachesize

Size of kernel cache (in MB). Default is 40.

tolerance

Tolerance of termination criterion.

scale

Logical; whether to scale inputs. Default is TRUE.

shrinking

Logical; whether to use shrinking heuristics. Default is TRUE.

cross

Number of folds for cross-validation. Default is 0, no cross validation.

probability

Logical; whether to enable probability model. Default is FALSE.

fitted

Logical; whether to keep fitted values. Default is TRUE.

subset

Optional vector specifying subset of observations to be used in the training fit.

na.action

Function which indicates what should happen when the data contain NAs.

Value

A list containing:

best_params

A list with the best values for 'cost', 'gamma', and 'epsilon'.

total_iter

Total number of iterations run by the optimizer.

model

The final trained SVR model (using 'e1071::svm').

time

Total training time in HMS format.

Examples

{
set.seed(1)
x <- matrix(rnorm(100), ncol = 2)
y <- x[,1] * 3 + rnorm(50)
model <- svrHybrid(x_train = x[1:40,], y_train = y[1:40],
                   x_test = x[41:50,], y_test = y[41:50],
                   kernel = "radial", optimizer = "AO",
                   objective = "RMSE", is.y.normalize = FALSE)
# To
model$best_params
}


metaSVR documentation built on Aug. 21, 2025, 5:58 p.m.