softMarginVectorLoss: Soft Margin Vector Loss function for multiclass SVM

Description Usage Arguments Value References Examples

Description

Soft Margin Vector Loss function for multiclass SVM

Usage

1
softMarginVectorLoss(x, y, l = 1 - table(seq_along(y), y))

Arguments

x

instance matrix, where x(t,) defines the features of instance t

y

target vector where y(t) is an integer encoding target of x(t,). If it contains NAs, the return function is a non-convex loss for transductive multiclass-SVM.

l

loss matrix. l(t,p(t)) must be the loss for predicting target p(t) instead of y(t) for instance t. By default, the parameter is set to character value "0/1" so that the loss is set to a 0/1 loss matrix.

Value

a function taking one argument w and computing the loss value and the gradient at point w

References

Teo et al. A Scalable Modular Convex Solver for Regularized Risk Minimization. KDD 2007

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  # -- Build a 2D dataset from iris, and add an intercept
  x <- cbind(intercept=100,data.matrix(iris[c(1,2)]))
  y <- iris$Species
  
  # -- build the multiclass SVM model
  w <- nrbm(softMarginVectorLoss(x,y))
  table(predict(w,x),y)
  
  # -- Plot the dataset, the decision boundaries, the convergence curve, and the predictions
  gx <- seq(min(x[,2]),max(x[,2]),length=200) # positions of the probes on x-axis
  gy <- seq(min(x[,3]),max(x[,3]),length=200) # positions of the probes on y-axis
  Y <- outer(gx,gy,function(a,b) {predict(w,cbind(100,a,b))})
  image(gx,gy,unclass(Y),asp=1,main="dataset & decision boundaries",
        xlab=colnames(x)[2],ylab=colnames(x)[3])
  points(x[,-1],pch=19+as.integer(y))

bmrm documentation built on May 2, 2019, 2:49 p.m.