Learn R Programming

bmrm (version 3.3)

binaryClassificationLosses: Loss functions for binary classification

Description

Loss functions for binary classification

Usage

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

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

rocLoss(x, y)

fbetaLoss(x, y, beta = 1)

Arguments

x

matrix of training instances (one instance by row)

y

a 2-levels factor representing the training labels for each instance in x

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.

beta

a numeric value setting the beta parameter is the f-beta score

Value

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

Functions

  • hingeLoss: Hinge Loss for Linear Support Vector Machine (SVM)

  • logisticLoss: logistic regression

  • rocLoss: Find linear weights maximize area under its ROC curve

  • fbetaLoss: F-beta score loss function

References

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

See Also

bmrm

Examples

Run this code
# NOT RUN {
  x <- cbind(intercept=100,data.matrix(iris[1:2]))
  y <- ifelse(iris$Species=="setosa","setosa","not_setosa")
  w <- bmrm(hingeLoss(x,y)); f <- x %*% w; Y <- sign(f)
  w <- bmrm(logisticLoss(x,y)); f <- x %*% w; Y <- exp(f) / (1+exp(f));
  w <- bmrm(rocLoss(x,y)); f <- x %*% w;
  w <- bmrm(fbetaLoss(x,y)); f <- x %*% w;
# }

Run the code above in your browser using DataLab