Skip to main content

MCC-F1 Curve

Project description

MCC-F1 Python package

Recently, the MCC-F1 curve has been proposed as an alternative, better way of assessing the performance of score-based binary classifiers [1].

This Python package implements a function to compute the MCC-F1 curve, namely mcc_f1_curve, similarly to the precision_recall_curve and roc_curve functions of scikit-learn.

Installation

pip install py-mcc-f1

Usage

from mcc_f1 import mcc_f1_curve, plot_mcc_f1_curve

import numpy as np
import matplotlib.pyplot as plt

from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split

# Load data and train model
X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33)
clf = LogisticRegression().fit(X_train, y_train)

# Calculate MCC-F1 metric
# @TODO

# Get predictions and MCC-F1 curve points
y_score = clf.predict_proba(X_test)[:,1]
mcc, f1, thresholds = mcc_f1_curve(y_test, y_score)

# Plot MCC-F1 curve
plot_mcc_f1_curve(clf, X_test, y_test)

Please refer to the function's docstring for further comments and details.

Future enhancements

  • Function to plot the MCC-F1 curve, (e.g., plot_mcc_f1_curve), similar to sklearn/metrics/_plot/precision_recall_curve.py and sklearn/metrics/_plot/roc_curve.py;
  • Function to compute the MCC-F1 metric, as defined in section 2.2 of the original paper.

Contributing

If you would like to contribute to this package, please follow the common community guidelines.

Please, also keep in mind that the main goal of this project is to be of similar implementation and quality as scikit-learn. Pull requests should pass the existing unit-tests, and add new ones when necessary.

To run the tests:

make test

License

This package is distributed under the MIT license.

References

  1. [2006.11278] The MCC-F1 curve: a performance evaluation technique for binary classification

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

py-mcc-f1-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

py_mcc_f1-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file py-mcc-f1-0.1.0.tar.gz.

File metadata

  • Download URL: py-mcc-f1-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for py-mcc-f1-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd081e47363da01bb3daa9d14b51e9f2926d278344374b6c5ed2bd3eee3ee469
MD5 8bfa71eaf78eb0a5d0c80ffaca3fd664
BLAKE2b-256 9d201216cbf437eaabbf7fc69457c30f48920b291884d0926a0bec4602a54102

See more details on using hashes here.

File details

Details for the file py_mcc_f1-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_mcc_f1-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for py_mcc_f1-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b1bd8c5be42dd8ffe4d1f1b0cb0e7600e8027815ae4d38e8e0a638876648497
MD5 3d4f180b3d4896a3d7491f67539a9ad0
BLAKE2b-256 ab71413b3e49dc92a359f0e99966e56387165622f245068b30d664d40a32cc70

See more details on using hashes here.

Supported by

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