google / jaxopt

Hardware accelerated, batchable and differentiable optimizers in JAX.
https://jaxopt.github.io
Apache License 2.0
939 stars 66 forks source link

Add (binary) hinge loss and multi-class hinge loss #389

Closed georgedahl closed 1 year ago

georgedahl commented 1 year ago

This feature request is to add support for the hinge loss, similar to how scikit-learn supports binary and multiclass hinge loss https://scikit-learn.org/stable/modules/generated/sklearn.metrics.hinge_loss.html

For the multiclass version, the one from http://jmlr.csail.mit.edu/papers/volume2/crammer01a/crammer01a.pdf

mblondel commented 1 year ago

I would add binary_hinge_loss, multiclass_hinge_loss, binary_perceptron_loss and multiclass_perceptron_loss. The perceptron loss is similar to the hinge loss but without the margin.

For the binary case, I suggest that we use 0 and 1 labels for consistency with the rest of the losses in JAXopt.

mblondel commented 1 year ago

Here are the formulas:

where signed_label = 2 * label - 1

froystig commented 1 year ago

Closed by @q-berthet in https://github.com/google/jaxopt/commit/60259a486255574a885fbd4fed533574791f087f!