lssvm

0th

Percentile

Least Squares Support Vector Machine

The lssvm function is an implementation of the Least Squares SVM. lssvm includes a reduced version of Least Squares SVM using a decomposition of the kernel matrix which is calculated by the csi function.

Keywords
methods, classif, nonlinear
Usage
# S4 method for formula
lssvm(x, data=NULL, ..., subset, na.action = na.omit, scaled = TRUE)

# S4 method for vector lssvm(x, ...)

# S4 method for matrix lssvm(x, y, scaled = TRUE, kernel = "rbfdot", kpar = "automatic", type = NULL, tau = 0.01, reduced = TRUE, tol = 0.0001, rank = floor(dim(x)[1]/3), delta = 40, cross = 0, fit = TRUE, ..., subset, na.action = na.omit)

# S4 method for kernelMatrix lssvm(x, y, type = NULL, tau = 0.01, tol = 0.0001, rank = floor(dim(x)[1]/3), delta = 40, cross = 0, fit = TRUE, ...)

# S4 method for list lssvm(x, y, scaled = TRUE, kernel = "stringdot", kpar = list(length=4, lambda = 0.5), type = NULL, tau = 0.01, reduced = TRUE, tol = 0.0001, rank = floor(dim(x)[1]/3), delta = 40, cross = 0, fit = TRUE, ..., subset)

Arguments
x

a symbolic description of the model to be fit, a matrix or vector containing the training data when a formula interface is not used or a kernelMatrix or a list of character vectors.

data

an optional data frame containing the variables in the model. By default the variables are taken from the environment which `lssvm' is called from.

y

a response vector with one label for each row/component of x. Can be either a factor (for classification tasks) or a numeric vector (for classification or regression - currently nor supported -).

scaled

A logical vector indicating the variables to be scaled. If scaled is of length 1, the value is recycled as many times as needed and all non-binary variables are scaled. Per default, data are scaled internally to zero mean and unit variance. The center and scale values are returned and used for later predictions.

type

Type of problem. Either "classification" or "regression". Depending on whether y is a factor or not, the default setting for type is "classification" or "regression" respectively, but can be overwritten by setting an explicit value. (regression is currently not supported)

kernel

the kernel function used in training and predicting. This parameter can be set to any function, of class kernel, which computes a dot product between two vector arguments. kernlab provides the most popular kernel functions which can be used by setting the kernel parameter to the following strings:

  • rbfdot Radial Basis kernel "Gaussian"

  • polydot Polynomial kernel

  • vanilladot Linear kernel

  • tanhdot Hyperbolic tangent kernel

  • laplacedot Laplacian kernel

  • besseldot Bessel kernel

  • anovadot ANOVA RBF kernel

  • splinedot Spline kernel

  • stringdot String kernel

Setting the kernel parameter to "matrix" treats x as a kernel matrix calling the kernelMatrix interface.

The kernel parameter can also be set to a user defined function of class kernel by passing the function name as an argument.

kpar

the list of hyper-parameters (kernel parameters). This is a list which contains the parameters to be used with the kernel function. For valid parameters for existing kernels are :

  • sigma inverse kernel width for the Radial Basis kernel function "rbfdot" and the Laplacian kernel "laplacedot".

  • degree, scale, offset for the Polynomial kernel "polydot"

  • scale, offset for the Hyperbolic tangent kernel function "tanhdot"

  • sigma, order, degree for the Bessel kernel "besseldot".

  • sigma, degree for the ANOVA kernel "anovadot".

  • length, lambda, normalized for the "stringdot" kernel where length is the length of the strings considered, lambda the decay factor and normalized a logical parameter determining if the kernel evaluations should be normalized.

Hyper-parameters for user defined kernels can be passed through the kpar parameter as well.

kpar can also be set to the string "automatic" which uses the heuristics in sigest to calculate a good sigma value for the Gaussian RBF or Laplace kernel, from the data. (default = "automatic").

tau

the regularization parameter (default 0.01)

reduced

if set to FALSE the full linear problem of the lssvm is solved, when TRUE a reduced method using csi is used.

rank

the maximal rank of the decomposed kernel matrix, see csi

delta

number of columns of cholesky performed in advance, see csi (default 40)

tol

tolerance of termination criterion for the csi function, lower tolerance leads to more precise approximation but may increase the training time and the decomposed matrix size (default: 0.0001)

fit

indicates whether the fitted values should be computed and included in the model or not (default: 'TRUE')

cross

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 Mean Squared Error for regression

subset

An index vector specifying the cases to be used in the training sample. (NOTE: If given, this argument must be named.)

na.action

A function to specify the action to be taken if NAs are found. The default action is na.omit, which leads to rejection of cases with missing values on any required variable. An alternative is na.fail, which causes an error if NA cases are found. (NOTE: If given, this argument must be named.)

additional parameters

Details

Least Squares Support Vector Machines are reformulation to the standard SVMs that lead to solving linear KKT systems. The algorithm is based on the minimization of a classical penalized least-squares cost function. The current implementation approximates the kernel matrix by an incomplete Cholesky factorization obtained by the csi function, thus the solution is an approximation to the exact solution of the lssvm optimization problem. The quality of the solution depends on the approximation and can be influenced by the "rank" , "delta", and "tol" parameters.

Value

An S4 object of class "lssvm" containing the fitted model, Accessor functions can be used to access the slots of the object (see examples) which include:

alpha

the parameters of the "lssvm"

coef

the model coefficients (identical to alpha)

b

the model offset.

xmatrix

the training data used by the model

References

J. A. K. Suykens and J. Vandewalle Least Squares Support Vector Machine Classifiers Neural Processing Letters vol. 9, issue 3, June 1999

See Also

ksvm, gausspr, csi

Aliases
  • lssvm
  • lssvm-methods
  • lssvm,formula-method
  • lssvm,vector-method
  • lssvm,matrix-method
  • lssvm,list-method
  • lssvm,kernelMatrix-method
  • show,lssvm-method
  • coef,lssvm-method
  • predict,lssvm-method
Examples
# NOT RUN {
## simple example
data(iris)

lir <- lssvm(Species~.,data=iris)

lir

lirr <- lssvm(Species~.,data= iris, reduced = FALSE)

lirr

## Using the kernelMatrix interface

iris <- unique(iris)

rbf <- rbfdot(0.5)

k <- kernelMatrix(rbf, as.matrix(iris[,-5]))

klir <- lssvm(k, iris[, 5])

klir

pre <- predict(klir, k)
# }
Documentation reproduced from package kernlab, version 0.9-27, License:

Community examples

Looks like there are no examples yet.