ccsvm_fit | R Documentation |
ccsvm
is used to train a subject weighted support vector machine where the weights are provided iteratively from robust loss function with the IRCO algorithm. It can be used to carry out robust regression and binary classification.
ccsvm_fit(x, y, weights, cfun="ccave", s=NULL, delta=0.0001, type = NULL, kernel="radial", cost=1, epsilon = 0.1, iter=10, reltol=1e-5, trace=FALSE, ...)
x |
a data matrix, a vector, or a sparse 'design matrix' (object of class
|
y |
a response vector with one label for each row/component of
|
weights |
the weight of each subject. It should be in the same length of |
cfun |
character, type of convex cap (concave) function.
|
s |
tuning parameter of |
delta |
a small positive number provided by user only if |
type |
|
kernel |
the kernel used in training and predicting. You
might consider changing some of the following parameters, depending
on the kernel type.
|
cost |
cost of constraints violation (default: 1)—it is the
‘C’-constant of the regularization term in the Lagrange formulation. This is proportional to the inverse of |
epsilon |
epsilon in the insensitive-loss function (default: 0.1) |
iter |
number of iteration in the IRCO algorithm |
reltol |
convergency criteria in the IRCO algorithm |
trace |
If |
... |
additional parameters for function |
A case weighted SVM is fit by the IRCO algorithm, where the loss function is a composite function of cfun
otype
, plus a L\_2 penalty.
Additional arguments include degree, gamma, coef0
,
class.weights, cachesize, tolerance, shrinking, propbability, fitted
, the same as "wsvm"
in package WeightSVM.
An object of class "wsvm"
(see package WeightSVM) 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. |
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 2, 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))). |
Zhu Wang wangz1@uthscsa.edu
Zhu Wang (2020) Unified Robust Estimation, arXiv e-prints, https://arxiv.org/abs/2010.02848
print
, predict
, coef
and plot
.
data(iris) iris <- subset(iris, Species %in% c("setosa", "versicolor")) # default with factor response: model <- ccsvm(Species ~ ., data = iris, kernel="linear", trace=TRUE) model <- ccsvm(Species ~ ., data = iris) # alternatively the traditional interface: x <- subset(iris, select = -Species) y <- iris$Species model <- ccsvm(x, y) # test with train data pred <- predict(model, x) # (same as:) pred <- fitted(model) # Check accuracy: table(pred, y) # compute decision values and probabilities: pred <- predict(model, x, decision.values = TRUE) attr(pred, "decision.values") # visualize (classes by color, SV by crosses): plot(cmdscale(dist(iris[,-5])), col = as.integer(iris[,5]), pch = c("o","+")[1:100 %in% model$index + 1]) ## try regression mode on two dimensions # create data x <- seq(0.1, 5, by = 0.05) y <- log(x) + rnorm(x, sd = 0.2) # estimate model and predict input values m <- ccsvm(x, y) new <- predict(m, x) # visualize plot(x, y) points(x, log(x), col = 2) points(x, new, col = 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.