Skip to main content

A package with tools for plotting metrics

Project description

plot_metric

|PyPI-Versions| |doc_badge|

Librairie to simplify plotting of metric like ROC curve, confusion matrix etc..

Installation

Using pip :

.. code:: sh

pip install plot-metric

Example

Let's load a simple dataset and make a train & test set :

.. code:: python

from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
import pandas as pd

X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(pd.DataFrame(X), y, test_size=0.2, random_state=42)

Train our classifier and predict our test set :

.. code:: python

from sklearn.naive_bayes import GaussianNB

gnb = GaussianNB()
model = gnb.fit(X_train, y_train)
# Use predict_proba to predict probability of the class
y_pred = gnb.predict_proba(X_test)[:,1]

We can now use plot_metric to plot ROC Curve, distribution class and classification matrix :

.. code:: python

from plot_metric.functions import  BinaryClassification
import matplotlib.pyplot as plt
bc = BinaryClassification(y_test, y_pred, labels=[0, 1])

plt.figure(figsize=(10,9))
plt.subplot(141)
bc.plot_roc()
plt.subplot(142)
bc.plot_class_distribution()
plt.subplot(143)
bc.plot_confusion_matrix()
plt.subplot(144)
bc.plot_confusion_matrix(normalize=True)
plt.show()
bc.print_report()

>>>                    ________________________
>>>                   |  Classification Report |
>>>                    ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
>>>               precision    recall  f1-score   support
>>>            0       1.00      0.93      0.96        43
>>>            1       0.96      1.00      0.98        71
>>>    micro avg       0.97      0.97      0.97       114
>>>    macro avg       0.98      0.97      0.97       114
>>> weighted avg       0.97      0.97      0.97       114

.. image:: example/images/example_binary_classification.png

.. |PyPI-Versions| image:: https://img.shields.io/badge/plot__metric-v0.0.3-blue.svg :target: https://pypi.org/project/plot-metric/

.. |doc_badge| image:: https://readthedocs.org/projects/plot-metric/badge/?version=latest :target: https://plot-metric.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

plot_metric-0.0.4-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file plot_metric-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: plot_metric-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1

File hashes

Hashes for plot_metric-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b3507c12b704ea9b229e6afcab87e5073da47c5b28762ec3d051ae94e3113911
MD5 409580884864f66cb45485461bfc9495
BLAKE2b-256 3f69a0f2b48fd4aec52f72110d17986b55080a43a673821a60640dd198d2f0b6

See more details on using hashes here.

Supported by

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