Skip to main content

Binary classification ratios

logo-binary-classification-ratios

The package helps computing the quality metrics (ratios) arising in the binary classification. The binary classification is given by the confusion matrix. The confusion matrix is given by number of true positives (TP), true negatives (TN), false positives (FP) and false negatives (FN) generated by an algorithm or procedure.

The ratios are easier to interpret than the confusion matrix.

For example, the Accuracy is given by the ratio of all accurate responses to the total number of responses

$$ \mathrm{Accuracy} = \frac{\mathrm{TP} + \mathrm{TN}}{\mathrm{TP} + \mathrm{TN} + \mathrm{FP} + \mathrm{FN}}. $$

Another popular ratio is Recall

$$ \mathrm{Recall} = \frac{\mathrm{TP}}{\mathrm{TP} + \mathrm{FN}}. $$

Usage

There is a command-line utility binary-classification-ratios. The utility takes the optional arguments  -tp,  -tn,  -fp, and  -fn, computes the popular binary-classification ratios such as Accuracy, Recall, Precision and F1-score and prints them to terminal.

binary-classification-ratios -tp 10 -tn 20 -fp 30 -fn 40
Confusion matrix TP 10 TN 20 FP 30 FN 40
     accuracy 0.30000
    precision 0.250
       recall 0.200
     f1-score 0.222

The package is designed to be useful in other Python projects where the elements of the confusion matrix are known

from binary_classification_ratios import BinaryClassificationRatios

ratios = BinaryClassificationRatios(tp=10, tn=20, fp=30, fn=40)
print(ratios.get_summary())

ratios.assert_min(0.9, 0.8, 0.7)

Install

pip install binary-classification-ratios

Metadata

Release files for binary-classification-ratios 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for binary-classification-ratios 0.3.0
File Size Uploaded
binary_classification_ratios-0.3.0.tar.gz 51.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for binary-classification-ratios 0.3.0
File Interpreter ABI Platform
binary_classification_ratios-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.6 kB

Release files / binary_classification_ratios-0.3.0.tar.gz

Download URL binary_classification_ratios-0.3.0.tar.gz
Size 51.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6a7bd33ccb3ad2467109f2c9d6b590f501c2b79341c56522c0a9074050ffdec0
BLAKE2b-256 checksum
How to use checksums
63463f49fd12752428032b515077fa271fb058fa66ac115884c2f39cba3631f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.12

Release files / binary_classification_ratios-0.3.0-py3-none-any.whl

Download URL binary_classification_ratios-0.3.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f68b071c0f5a0b4f5b5a0427c43182f529322355dc50c00489cd34f2430759da
BLAKE2b-256 checksum
How to use checksums
1f9554adb9fd9ab8d68457dab00f9cbeceec8197e6ba16d23f34ffd4fb88e98b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.12

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page