Description Usage Arguments Details Value Note References See Also
This is a modification of the svm
function in package e1071 that can deal with
observation weights.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | wsvm(x, ...)
## S3 method for class 'formula'
wsvm(formula, data = NULL,
case.weights = rep(1, nrow(data)), ..., subset,
na.action = na.omit, scale = TRUE)
## Default S3 method:
wsvm(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, class.weights = NULL,
case.weights = rep(1, nrow(x)), cachesize = 40,
tolerance = 0.001, epsilon = 0.1, shrinking = TRUE,
cross = 0, probability = FALSE, fitted = TRUE,
seed = 1L, ..., subset = NULL, na.action = na.omit)
|
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 |
x |
(Required if no |
y |
(Only if no |
scale |
A logical vector indicating the variables to
be scaled. If |
type |
|
kernel |
The kernel used in training and predicting.
You might consider changing some of the following
parameters, depending on the kernel type.
|
degree |
Parameter needed for kernel of type
|
gamma |
Parameter needed for all kernels except
|
coef0 |
Parameter needed for kernels of type
|
cost |
Cost of constraints violation (default: 1) — it is the ‘C’-constant of the regularization term in the Lagrange formulation. |
nu |
Parameter needed for |
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. |
case.weights |
A vector of observation weights (default: a vector of 1s). |
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: |
cross |
If an 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. |
fitted |
Logical indicating whether the fitted
values should be computed and included in the model or
not (default: |
probability |
Logical indicating whether the model
should allow for probability predictions (default:
|
seed |
Integer seed for libsvm (used for cross-validation and probability prediction models). |
... |
Additional parameters for the low level
fitting function |
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 |
wsvm
is used to train a support vector machine
with case weights. It can be used to carry out general
regression and classification (of nu and epsilon-type),
as well as density-estimation. A formula interface is
provided.
This function is a modification of the
svm
function in package e1071
written by David Meyer (based on C/C++-code by Chih-Chung
Chang and Chih-Jen Lin). An extension of LIBSVM that can
deal with case weights written by Ming-Wei Chang,
Hsuan-Tien Lin, Ming-Hen Tsai, Chia-Hua Ho and Hsiang-Fu
Yu is used. It is available at
http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/#weights_for_data_instances.
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.
plot.svm
allows a simple graphical visualization
of classification models.
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.
Data are scaled internally, usually yielding better results. Parameters of SVM-models usually must be tuned to yield sensible results!
An object of class "wsvm"
, inheriting from
"svm"
containing the fitted model, including:
SV |
The resulting support vectors (possibly scaled). |
index |
The index of the resulting support
vectors in the data matrix. Note that this index refers
to the preprocessed data (after the possible effect of
|
coefs |
The corresponding coefficients times the training labels. |
rho |
The negative intercept. |
obj |
The value(s) of the objective function. |
sigma |
In case of a probabilistic regression model, the scale parameter of the hypothesized (zero-mean) laplace distribution estimated by maximum likelihood. |
probA,
probB |
numeric vectors of length k(k-1)/2, k number of classes, containing the parameters of the logistic distributions fitted to the decision values of the binary classifiers (1 / (1 + exp(a x + b))). |
This modification is not well-tested.
Chang, Chih-Chung and Lin, Chih-Jen:
LIBSVM: a
library for Support Vector Machines
http://www.csie.ntu.edu.tw/~cjlin/libsvm
Exact formulations of models, algorithms, etc. can be
found in the document:
Chang, Chih-Chung and Lin,
Chih-Jen:
LIBSVM: a library for Support Vector
Machines
http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.ps.gz
More implementation details and speed benchmarks can be
found on: Rong-En Fan and Pai-Hsune Chen and Chih-Jen
Lin:
Working Set Selection Using the Second
Order Information for Training SVM
http://www.csie.ntu.edu.tw/~cjlin/papers/quadworkset.pdf
predict.wsvm
, plot.svm
in package e1071, matrix.csr
(in package SparseM).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.