bmrm (version 4.1)

multivariateHingeLoss: The loss function for multivariate hinge loss

Description

The loss function for multivariate hinge loss

Usage

multivariateHingeLoss(x, y, loss.weights = 1)

Arguments

x

matrix of training instances (one instance by row)

y

logical matrix of targets: y(t,) is the vector of binary labels for x(t,)

loss.weights

numeric vector of loss weights to incure for each instance of x. Vector length should match nrow(x), but values are cycled if not of identical size.

Value

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

See Also

nrbm

Examples

Run this code
# NOT RUN {
  x <- cbind(intercept=100,data.matrix(iris[1:4]))
  y <- model.matrix(~iris$Species+0)>0
  w <- nrbm(multivariateHingeLoss(x,y),LAMBDA=1)
  table(y,predict(w,x)>0,col(y))
  table(
    do.call(paste0,as.data.frame(y+0)),
    do.call(paste0,as.data.frame((predict(w,x)>0)+0))
  )
  
# }

Run the code above in your browser using DataLab