bmrm (version 4.1)

ontologyLoss: Ontology Loss Function

Description

Ontology loss function may be used when the class labels are organized has an ontology structure

Usage

ontologyLoss(x, y, l = 1 - table(seq_along(y), y),
  dag = diag(nlevels(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,)

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 a 0/1 loss matrix.

dag

a numeric matrix defining the path in the Direct Acyclic Graph (DAG) to each class label

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

Run this code
# NOT RUN {
  # -- Load the data
  x <- cbind(intercept=100,data.matrix(iris[1:4]))
  dag <- matrix(nrow=nlevels(iris$Species),byrow=TRUE,dimnames=list(levels(iris$Species)),c(
      1,0,0,0,
      0,1,1,0,
      0,1,0,1
  ))
  w <- nrbm(ontologyLoss(x,iris$Species,dag=dag))
  table(predict(w,x),iris$Species)
# }

Run the code above in your browser using DataCamp Workspace