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 datagain_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
Metadata
Release files for agc 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| agc-0.0.5.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agc-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.3 kB
Release files / agc-0.0.5.tar.gz
| Download URL | agc-0.0.5.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31fa50b8015745fe2c302d69a9f176cf77f1379d79180b831315b7e30321a8cb
|
|
BLAKE2b-256 checksum How to use checksums |
c6ad6888fe6b0205f8bb31c9c2af9c1a4683f0fe17e6427f2434a8c251bae319
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9
|
Release files / agc-0.0.5-py3-none-any.whl
| Download URL | agc-0.0.5-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
467485d687d63c384f74642f428ea127a67774bf1c7268b9277482df132bb998
|
|
BLAKE2b-256 checksum How to use checksums |
d6d13e9bafc419ad96c5d54607fc51da85e1ff5a8f34d2d31ba9c61ba5f3061c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9
|