Linearly Programmed L1-loss Linear Support Vector Machine with L1 regularization
Usage
svmLP(x, y, LAMBDA = 1, loss.weights = 1)
# S3 method for svmLP
predict(object, x, ...)
svmMulticlassLP(x, y, LAMBDA = 1, loss.weights = 1)
# S3 method for svmMLP
predict(object, x, ...)
Arguments
x
a numeric data matrix to predict
y
a response factor for each row of x. It must be a 2 levels factor for svmLP, or a >=2 levels factor for svmMulticlassLP
LAMBDA
control the regularization strength in the optimization process. This is the value used as coefficient of the regularization term.
loss.weights
numeric vector of loss weights to incure for each instance of x.
Vector length should match length(y), but values are cycled if not of identical size.
object
an object of class svmLP or svmMLP
...
unused, present to satisfy the generic predict() prototype
Value
the optimized weights matrix, with class svmLP
predict() return predictions for row of x, with an attribute "decision.value"
predict() return predictions for row of x, with an attribute "decision.value"
Functions
svmLP: linear programm solving binary-SVM with L1-regularization and L1-norm
svmMulticlassLP: linear programm solving multiclass-SVM with L1-regularization and L1-norm
Details
svmLP solves a linear program implementing a linear SVM
with L1 regularization and L1 loss. It solves:
min_w LAMBDA*|w| + sum_i(e_i);
s.t. y_i * <w.x_i> >= 1-e_i; e_i >= 0
where |w| is the L1-norm of w
svmMulticlassLP solves a linear program implementing multiclass-SVM
with L1 regularization and L1 loss. It solves:
min_w LAMBDA*|w| + sum_i(e_i);
s.t. <w.x_i> - <w.x_j> >= 1-e_i; e_i >= 0
where |w| is the L1-norm of w
# NOT RUN { x <- cbind(100,data.matrix(iris[1:4]))
y <- iris$Species
w <- svmMulticlassLP(x,y)
table(predict(w,x),y)
w <- svmLP(x,y=="setosa")
table(predict(w,x),y)
# }