Skip to main content

TakeConfusionMatrix is a tool for batched metrics calculations

Project description

TakeConfunsionMatrix

TakeConfusionMatrix is a Python package for batched Machine Learning metrics calculation and is distributed under MIT License.

Goal

The main goal of this package is to enable calculation of Machine Learning metrics for hundreds of milions of results through batch computation.

Features

The current package features are:

  • Confusion Matrix
    • Image output
    • Normalized output
    • Custom labelled output
  • Precision Score
  • Recall Score
  • F1-Score
  • Accuracy Score (Exact Match Ratio)

Installation

Dependencies

TakeConfusionMatrix requires:

  • Python (>= 3.8)
  • Pandas (>= 1.0.4)
  • scikit-learn (>= 0.23.1)

User installation

Install the 64bit version of Python, for instance from https://www.python.org/. Then run:

pip install -U TakeConfusionMatrix

VirutalEnv installation

In order to avoid potential conflicts with other packages it is strongly recommended to use a virtual environment, e.g. python3 virtualenv (see python3 virtualenv documentation) or conda environments.

To do so, install the 64bit version of Python3 if you doesn't have it yet, then run:

python3 -m venv venv
source venv/bin/activate
pip install -U TakeConfusionMatrix

NOTE: Please note that the above instructions assume a Linux-based SO. If you are using another environment, see scikit-learn installation documentation.

Usage

Here the package's features are briefly presented. For more advanced examples, please refer to the methods documentation.

Matrix computation

# Import MetricsComputation class
from take_confusion_matrix import MetricsCalculation

# Initialize class
labels = [0, 1, 2]
mc = MetricsCalculator(labels)

# Compute matrix
y_true = [0, 1, 0, 1]
y_pred = [0, 0, 0, 0]
mc.compute_matrix(y_true, y_pred)

y_true = [0, 2, 0, 2]
y_pred = [0, 0, 0, 0]
mc.compute_matrix(y_true, y_pred)

# Generate matrix
confusion_matrix = mc.generate_confusion_matrix()
print(confusion_matrix)

Normalized matrix

confusion_matrix = mc.generate_confusion_matrix(normalize=True)

Custom labelled matrix

labels = ['class_0', 'class_1', 'class_2']
confusion_matrix = mc.generate_confusion_matrix(labels=labels)

Label free matrix

confusion_matrix = mc.generate_confusion_matrix(with_labels=False)

Metrics computation

# Import MetricsComputation class
from take_confusion_matrix import MetricsCalculation

# Initialize class
labels = [0, 1, 2]
mc = MetricsCalculator(labels)

# Compute matrix
y_true = [0, 1, 0, 1]
y_pred = [0, 0, 0, 0]
mc.compute_matrix(y_true, y_pred)

y_true = [0, 2, 0, 2]
y_pred = [0, 0, 0, 0]
mc.compute_matrix(y_true, y_pred)

# Generate metics
metrics = mc.generate_metrics()
print(metrics)

Testing

In order to test package's features, you must download the code and change you current directory (cd) to the package's one. After that, open a terminal inside package's folder and type:

pytest

All tests are stored inside tests folders, meaning that any test folder named tests contains a test set.

Maintainer

Take's D&A Team | analytics.ped@take.net

Author

Cecília Regina Oliveira de Assis | @ceciliassis

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

TakeConfusionMatrix-0.0.3.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

TakeConfusionMatrix-0.0.3-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file TakeConfusionMatrix-0.0.3.tar.gz.

File metadata

  • Download URL: TakeConfusionMatrix-0.0.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for TakeConfusionMatrix-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b63bbfb42d4a59a61415d6ae4d8c34e6d1ea238a1a1dc0e0791bf349f08a9b2f
MD5 f3d6547556fc92ffc05e98a8db147b64
BLAKE2b-256 c1e38a883bc4493cbc2ac8eaea42135d8058e086b6ca579de5238b5bbac05301

See more details on using hashes here.

File details

Details for the file TakeConfusionMatrix-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: TakeConfusionMatrix-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for TakeConfusionMatrix-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 346f61693dd25dd5da412e245f045b20dbcdfcbc6d55149c29f1e504cf4064ab
MD5 6160a664a99b49da00074d6295a65878
BLAKE2b-256 fbbf8c4c4b77fe4d5c4f98842bbc73bf07e2d3a886273dd18f006d5816f53d0a

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