Skip to main content

ROC aggregator

Project description

roc-aggregator

Aggregates the ROCs obtained from multiple sources into one global ROC. Additionally, it's also possible to calculate the precision-recall curve.

Usage

Install the package using one of the following options:

  • pip3: pip3 install roc-aggregator
  • this repository pip3 install .

Example:

  • Obtain the global ROC curve from different sources by providing the false positive rate (fpr), true positive rate (tpr), thresholds (thresh), the total number of negative samples, and the total number of samples from each source:
fpr_1 = [0, 0, 0, 0, 0.002, ...] # false positive rate values for each threshold
tpr_1 = [0, 0.004, 0.008, 0.012, 0.016, ...] # true positive rate values for each threshold
thresh_1 = [0.9994038, 0.9986345, 0.99847864, 0.99575908, 0.99567612] # thresholds used
negative_count_1 = np.count_nonzero(y1 == 0) # count the number of negative labels
total_count_1 = len(y1) # total number of labels

...

fpr, tpr, thresh_stack = roc_curve(
    [fpr_1, fpr_2, ...],
    [tpr_1, tpr_2, ...],
    [thresh_1, thresh_2, ...],
    [negative_count_1, negative_count_2, ...],
    [total_count_1, total_count_2, ...]
)
  • Calculate the AUC using numpy:
np.trapz(tpr, fpr)

A complete example of the usage of the roc-aggregator can be found here.

Visualization

plt.style.use('seaborn')
plt.plot(fpr, tpr, color=color, label=label, linestyle=linestyle)
plt.legend()
plt.title('ROC curve')
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive rate')
plt.savefig('ROC',dpi=300)
plt.show()

Testing

Unit tests are available at /roc-aggregator/tests. Install the dependencies required and run the tests using pytest or python3 setup.py test.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roc_aggregator-1.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

roc_aggregator-1.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file roc_aggregator-1.1.0.tar.gz.

File metadata

  • Download URL: roc_aggregator-1.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.2

File hashes

Hashes for roc_aggregator-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3503085588ef30eb674398f9cc2d36e5db158d6aa506f09f5fb6421ae194fd21
MD5 fe90832c8cba6616b70ccb8a023a7f66
BLAKE2b-256 15553e3f4d54daef533534f3d0329e9f2cd35a0e6910ca3f7fe32bfc64b163b2

See more details on using hashes here.

File details

Details for the file roc_aggregator-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: roc_aggregator-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.2

File hashes

Hashes for roc_aggregator-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd62634625484538a1d8a500a7dea78d735ab64bb69c6f3d8ba2536e8b547f17
MD5 7a8cc430d4e94d3fa5263c76a53f6ccb
BLAKE2b-256 d0d1d67001eeb65c30065e6461b2e671a2289bfc5ff61f6dbcd14f3ebccdf3ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page