Catalog PyPI
Back to packageRELEASE DETAILS

0.0.5

PyPI

agc

Python code to compute and plot (truncated, weighted) area under gain curves (agc)

Published26 Aug 2022
Direct dependencies3
Transitive dependenciesNot calculated

README

Version 0.0.5 documentation

AGC - Area under Gain Curves

Python code to compute and plot (truncated, weighted) area under gain curves (AGC)

For binary classification, gain curves are a nice alternative to ROC curves in that they can naturally be truncated to focus on the top scoring points only. Moreover, the data points can have weights. In this code, we provide two functions:

  • agc_score: Compute the area under the gain curve (AGC) for binary labelled data
  • gain_curve: Compute the proportion of data points and true positive rate for all thresholds, for plotting

The first function returns the normalized area by default (improvement over random, so this could be negative). The functions can be imported from the supplied agc.py file, or installed via pip install agc.

A simple example

## create toy binary labels and scores for illustration
labels = np.concatenate((np.repeat(1,100),np.repeat(0,900)))
scores = np.concatenate((np.random.uniform(.4,.8,100),np.random.uniform(.2,.6,900)))

## compute (normalized) area under the gain curve
print(agc_score(labels, scores))

## compute (un-normalized) area under the gain curve
print(agc_score(labels, scores, normalized=False))

## now the area for the top scoring 10% of the points
print(agc_score(labels, scores, truncate=0.1))

## or top scoring 100 points
print(agc_score(labels, scores, truncate=100))

More details in Notebooks:

For a quick introduction, see the following notebook: https://github.com/ftheberge/agc/blob/main/agc/agc_intro.ipynb also available in markup format: https://github.com/ftheberge/agc/blob/main/intro/agc_intro.md

For more details, see the notebook: https://github.com/ftheberge/agc/blob/main/agc/agc.ipynb also available in markup format: https://github.com/ftheberge/agc/blob/main/example/agc.md

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
numpy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
numpyruntime
pandas
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pandasruntime
scipy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
scipyruntime

Distribution files

2 collected
agc-0.0.5-py3-none-any.whl

bdist_wheel · 4.72 KB · Python py3

Source file
agc-0.0.5.tar.gz

sdist · 4.37 KB · Python source

Source file

Repository

PENDING
ftheberge/agc

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:20 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:54f2b3c973b1936a2e4929d2f2fa8318da7f5ae72e38000f6bc149670902eb99

Other collected versions

View all collected versions →