tdhock / aum

1 stars 2 forks source link

Area Under the Minimum (AUM) of False Positives and Negatives

| [[file:tests/testthat][tests]] | [[https://github.com/tdhock/aum/actions][https://github.com/tdhock/aum/workflows/R-CMD-check/badge.svg]] | [[https://github.com/jimhester/covr][coverage]] | [[https://coveralls.io/github/tdhock/aum?branch=master][https://coveralls.io/repos/tdhock/aum/badge.svg?branch=main&service=github]] |

This R package provides an efficient C++ implementation of the [[https://jmlr.org/papers/v24/21-0751.html][AUM]], which can be used as a surrogate loss for optimizing Area Under the ROC Curve (AUC) in supervised binary classification and changepoint detection problems.

** Installation

+begin_src R

install.packages("aum")

OR:

if(!requireNamespace("remotes"))install.packages("remotes") remotes::install_github("tdhock/aum")

+end_src

** Usage

*** Converting binary labels to aum_diffs

The code below creates an =aum_diffs= data table which represents error functions for two labeled examples in binary classification.

+begin_src R

(bin.diffs <- aum::aum_diffs_binary(c(0,1))) example pred fp_diff fn_diff 1: 0 0 1 0 2: 1 0 0 -1

+end_src

*** Computing AUM from aum_diffs table and prediction vector

Next we assume predicted values of 0 for both examples, and then compute Area Under the Minimum (AUM) of False Positives and False Negatives and its directional derivatives.

+begin_src R

aum::aum(bin.diffs, c(0,0)) $aum [1] 0

$derivative_mat [,1] [,2] [1,] 0 1 [2,] -1 0

+end_src

The result above is a named list with two elements.

*** Changepoint detection

See =?aum::aum_diffs_penalty= for documentation about how to compute the AUM for supervised penalty learning in changepoint detection problems.

*** Line search

An exact line search can be computed using time which is log-linear in the number of step sizes, see =?aum::aum_line_search= for a single line search, and =?aum::aum_linear_model_cv= for using the line search in each step of gradient descent when learning a linear model.

** Related Work