irsvm_fit {mpath} | R Documentation |
Fit iteratively reweighted support vector machines for robust loss functions
Description
irsvm_fit
is used to train a subject weighted support vector machine where the weights are provided iteratively from robust loss function with the iteratively reweighted convex optimization (IRCO). It can be used to carry out robust regression and binary classification. This does computing for the wrapper function irsvm
.
Usage
irsvm_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, ...)
Arguments
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 |
Details
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.
Value
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))). |
Author(s)
Zhu Wang zwang145@uthsc.edu
References
Zhu Wang (2024) Unified Robust Estimation, Australian & New Zealand Journal of Statistics. 66(1):77-102.
See Also
irsvm
, print
, predict
, coef
and plot
.
Examples
data(iris)
iris <- subset(iris, Species %in% c("setosa", "versicolor"))
# default with factor response:
model <- irsvm(Species ~ ., data = iris, kernel="linear", trace=TRUE)
model <- irsvm(Species ~ ., data = iris)
# alternatively the traditional interface:
x <- subset(iris, select = -Species)
y <- iris$Species
model <- irsvm(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 <- irsvm(x, y)
new <- predict(m, x)
# visualize
plot(x, y)
points(x, log(x), col = 2)
points(x, new, col = 4)