ossvm: Observation Specific Support Vector Machines

Description Usage Arguments Details Value See Also Examples

View source: R/ossvm.R

Description

A localized version of Support Vector Machines.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
ossvm(x, ...)

## S3 method for class 'formula'
ossvm(formula, data = NULL, ..., subset,
  na.action = na.omit, scale = TRUE)

## Default S3 method:
ossvm(x, y = NULL, scale = TRUE, type = NULL,
  kernel = "radial", degree = 3, gamma = if (is.vector(x)) 1 else
  1/ncol(x), coef0 = 0, cost = 1, nu = 0.5, wf = c("biweight", "cauchy",
  "cosine", "epanechnikov", "exponential", "gaussian", "optcosine",
  "rectangular", "triangular"), bw, k, nn.only = TRUE, class.weights = NULL,
  cachesize = 40, tolerance = 0.001, epsilon = 0.1, shrinking = TRUE,
  seed = 1L, ..., subset = NULL, na.action = na.omit)

Arguments

x

(Required if no formula is given as principal argument.) A data matrix, a vector, or a sparse matrix (object of class Matrix provided by the Matrix package, or of class matrix.csr provided by the SparseM package, or of class simple_triplet_matrix provided by the slam package).

formula

A symbolic description of the model to be fit.

data

An optional data frame containing the variables in the model. By default the variables are taken from the environment which ossvm is called from.

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.)

scale

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

y

(Only if no formula is given as principal argument.) 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 regression).

type

ossvm can be used as a classification machine, as a regression machine, or for novelty detection. Depending of whether y is a factor or not, the default setting for type is C-classification or eps-regression, respectively, but may be overwritten by setting an explicit value.
Valid options are:

  • C-classification

  • nu-classification

  • one-classification (for novelty detection)

  • eps-regression

  • nu-regression

kernel

The kernel used in training and predicting. 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

Parameter needed for kernel of type polynomial (default: 3).

gamma

Parameter needed for all kernels except linear (default: 1/(data dimension)).

coef0

Parameter needed for kernels of type polynomial and sigmoid (default: 0).

cost

Cost of constraints violation (default: 1)–it is the ‘C’-constant of the regularization term in the Lagrange formulation.

nu

Parameter needed for nu-classification, nu-regression, and one-classification.

wf

A window function which is used to calculate weights that are introduced into the fitting process. Either a character string or a function, e.g. wf = function(x) exp(-x). For details see the documentation for wfs.

bw

(Required only if wf is a string.) The bandwidth parameter of the window function. (See wfs.)

k

(Required only if wf is a string.) The number of nearest neighbors of the decision boundary to be used in the fitting process. (See wfs.)

nn.only

(Required only if wf is a string indicating a window function with infinite support and if k is specified.) Should only the k nearest neighbors or all observations receive positive weights? (See wfs.)

class.weights

A named vector of weights for the different classes, used for asymmetric class sizes. Not all factor levels have to be supplied (default weight: 1). All components have to be named.

cachesize

Cache memory in MB (default 40).

tolerance

Tolerance of termination criterion (default: 0.001).

epsilon

epsilon in the insensitive-loss function (default: 0.1).

shrinking

Option whether to use the shrinking-heuristics (default: TRUE).

seed

Integer seed for libsvm (used for probability prediction models).

...

Additional parameters for the low level fitting function ossvm.default.

Details

This is a localized version of the Support Vector Machine where for each test observation an individual SVM is fitted. Training observations are weighted according to their Euclidean distance from the test observation.

The name of the window function (wf) can be specified as a character string. In this case the window function is generated internally in predict.ossvm. Currently supported are "biweight", "cauchy", "cosine", "epanechnikov", "exponential", "gaussian", "optcosine", "rectangular" and "triangular".

Moreover, it is possible to generate the window functions mentioned above in advance (see wfs) and pass them to ossvm.

Any other function implementing a window function can also be used as wf argument. This allows the user to try own window functions. See help on wfs for details.

For multiclass-classification with k levels, k>2, ‘libsvm’ uses the 'one-against-one'-approach, in which k(k-1)/2 binary classifiers are trained; the appropriate class is found by a voting scheme.

‘libsvm’ internally uses a sparse data representation, which is also high-level supported by the package SparseM.

If the predictor variables include factors, the formula interface must be used to get a correct model matrix.

The probability model for classification fits a logistic distribution using maximum likelihood to the decision values of all binary classifiers, and computes the a-posteriori class probabilities for the multi-class problem using quadratic optimization. The probabilistic regression model assumes (zero-mean) laplace-distributed errors for the predictions, and estimates the scale parameter using maximum likelihood.

Value

An object of class "ossvm", a list containing all information about the SVM model to be fitted, mainly for internal use. It includes:

call

The (matched) function call.

x

The explanatory variables (already scaled if scaling was desired).

y

The response vector (appropriately modified).

wf

The window function used.

bw

(Only if wf is a string or was generated by means of one of the functions documented in wfs.) The bandwidth used, NULL if bw was not specified.

k

(Only if wf is a string or was generated by means of one of the functions documented in wfs.) The number of nearest neighbors used, NULL if k was not specified.

nn.only

(Logical. Only if wf is a string or was generated by means of one of the functions documented in wfs and if k was specified.) TRUE if only the k nearest neighbors receive a positive weight, FALSE otherwise.

adaptive

(Logical.) TRUE if the bandwidth of wf is adaptive to the local density of data points, FALSE if the bandwidth is fixed.

variant

(Only if wf is a string or one of the window functions documented in wfs is used, for internal use only). An integer indicating which weighting scheme is implied by bw, k and nn.only.

Moreover, information about the chosen SVM type, the kernel function and the SVM parameters is included.

See Also

predict.ossvm.

Other observation_specific svm: predict.ossvm

Other observation_specific svm: predict.ossvm

Other observation_specific svm: predict.ossvm

Examples

1
2
3
4
fit <- ossvm(Species ~ ., data = iris, wf = "gaussian", bw = 0.5, 
    kernel = "polynomial", coef0 = 0.5)
pred <- predict(fit)
mean(pred != iris$Species)

schiffner/locClass documentation built on May 29, 2019, 3:39 p.m.