svmr | R Documentation |
Function svmr
and svmc
are wrappers for fitting regression and discrimination SVM models, respectively, using function ksvm
of package kernlab
(thanks to Karatzoglou et al.) available on CRAN. This package uses the tool box LIVSIM (Chang & Lin, http://www.csie.ntu.edu.tw/~cjlin/libsvm).
The functions use parameterization 'C'
, not the 'nu'
parameterization.
The syntax and outputs are the same as for the other kernel models in package rnirs
.
See also the tuning facility with splitpar
. Usual preliminary ranges are for instance:
- C <- 10^(-5:15)
- epsilon <- seq(.1, .3, by = .1)
- sigma <- 10^(-6:3)
svmr(Xr, Yr, Xu, Yu = NULL, C = 1, epsilon = .1, kern = krbf,
print = TRUE, ...)
svmc(Xr, Yr, Xu, Yu = NULL, C = 1, epsilon = .1, kern = krbf,
print = TRUE, ...)
Xr |
A |
Yr |
A vector of length |
Xu |
A |
Yu |
A vector of length |
C |
A value, or vector of values, of the cost of constraints violation. This is the 'C'-constant of the regularization term in the Lagrange formulation |
epsilon |
A value, or vector of values, of |
kern |
A function defining the considered kernel (Default to |
print |
Logical (default = |
... |
Optionnal arguments to pass in the kernel function defined in |
A list of outputs (see examples), such as:
y |
Responses for the test data. |
fit |
Predictions for the test data. |
r |
Residuals for the test data. |
Karatzoglou, A. et al. 2019. Package kernlab: Kernel-Based Machine Learning Lab. Version 0.9-29 https://cran.r-project.org/
Chang C., Lin C.. LIBSVM: a library for Support Vector Machines http://www.csie.ntu.edu.tw/~cjlin/libsvm
data(datcass)
Xr <- datcass$Xr
yr <- datcass$yr
Xu <- datcass$Xu
yu <- datcass$yu
Xr <- detrend(Xr)
Xu <- detrend(Xu)
dim(Xr)
dim(Xu)
C <- 1e3
epsilon <- 0.1
sigma <- c(10, 100)
fm <- svmr(Xr, yr, Xu, yu, C = C, epsilon = epsilon, kern = krbf, sigma = sigma)
z <- mse(fm, ~ C + epsilon + sigma)
z[z$rmsep == min(z$rmsep), ][1, ]
data(datforages)
Xr <- datforages$Xr
yr <- datforages$yr
Xu <- datforages$Xu
yu <- datforages$yu
Xr <- savgol(snv(Xr), n = 21, p = 2, m = 2)
Xu <- savgol(snv(Xu), n = 21, p = 2, m = 2)
table(yr)
table(yu)
C <- 1e3
epsilon <- 0.1
sigma <- c(10, 100)
fm <- svmc(Xr, yr, Xu, yu, C = C, epsilon = epsilon, kern = krbf, sigma = sigma)
z <- err(fm, ~ C + epsilon + sigma)
z[z$errp == min(z$errp), ][1, ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.