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 tosklearn/metrics/_plot/precision_recall_curve.pyandsklearn/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
Metadata
Release files for py-mcc-f1 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py-mcc-f1-0.1.0.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_mcc_f1-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.2 kB
Release files / py-mcc-f1-0.1.0.tar.gz
| Download URL | py-mcc-f1-0.1.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd081e47363da01bb3daa9d14b51e9f2926d278344374b6c5ed2bd3eee3ee469
|
|
BLAKE2b-256 checksum How to use checksums |
9d201216cbf437eaabbf7fc69457c30f48920b291884d0926a0bec4602a54102
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / py_mcc_f1-0.1.0-py3-none-any.whl
| Download URL | py_mcc_f1-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b1bd8c5be42dd8ffe4d1f1b0cb0e7600e8027815ae4d38e8e0a638876648497
|
|
BLAKE2b-256 checksum How to use checksums |
ab71413b3e49dc92a359f0e99966e56387165622f245068b30d664d40a32cc70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|