Skip to main content

Binary classification ratios gathered in one package.

Project description

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 $\mathrm{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 $\mathrm{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

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

binary_classification_ratios-0.2.0.tar.gz (51.7 kB view details)

Uploaded Source

Built Distribution

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

binary_classification_ratios-0.2.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file binary_classification_ratios-0.2.0.tar.gz.

File metadata

File hashes

Hashes for binary_classification_ratios-0.2.0.tar.gz
Algorithm Hash digest
SHA256 957e690f618a3807515aa4141890f6abf4975eec78b1f477aec677dd45d95581
MD5 d7a9d5ac76a62b93127aa1078aa3fde9
BLAKE2b-256 38f015247c9a0e60ed56779ede09525af88cc37ebe01b84fb6b6d3ba0a2a5224

See more details on using hashes here.

File details

Details for the file binary_classification_ratios-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for binary_classification_ratios-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8461ddf47a68ebc5e052e920fc1c712ce2050aac6bd892bb47f5265d79f89966
MD5 4053f8eb4a539a64ed7b25e0a96e7af1
BLAKE2b-256 79d8d5fa71c62cf8f0922d359f1d235b81363840472740c616bbf9a5a2cc9353

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