Plot a pretty confusion matrix (like Matlab) in python using seaborn and matplotlib
Project description
ConfPlot: Plot Confusion Matrix in Python
Plot a pretty confusion matrix (like Matlab) in python using seaborn and matplotlib
This module lets you plot a pretty looking confusion matrix from a np matrix or from a prediction results and actual labels.
Sample plots:
Getting started
Installation
pip install confplot
Usage
Plot confusion matrix from matrix
# import package
import confplot
# assume you have a confusion matrix array like this
array = np.array(
[[13, 0, 1, 0, 2, 0],
[ 0, 50, 2, 0, 10, 0],
[ 0, 13, 16, 0, 0, 3],
[ 0, 0, 0, 13, 1, 0],
[ 0, 40, 0, 1, 15, 0],
[ 0, 0, 0, 0, 0, 20]]
)
# convert it to a pandas dataframe
df_cm = DataFrame(array, index=range(1, 7), columns=range(1, 7))
# create and save confusion matrix plot as "cm_plot.png"
confplot.plot_confusion_matrix_from_matrix(df_cm, outfile="cm_plot.png")
Plot confusion matrix from data
# import package
import confplot
# assume you have 1D y_true (actual values) and y_pred (predictions) arrays
y_true = ...
y_pred = ...
# arange targetclass names if you want
columns = ["ahududu", "ananas", "armut", "avokado", "ayva"]
# create and save confusion matrix plot as "cm_plot.png"
confplot.plot_confusion_matrix_from_data(
y_true,
y_pred,
columns,
outfile="cm_plot.png"
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file confplot-0.1.1.tar.gz.
File metadata
- Download URL: confplot-0.1.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82a303da39228f57111457fc7acf217998591c8246f1313a37d54627e161d20e
|
|
| MD5 |
15bf535338e6f1c5220b567ed40d4b4e
|
|
| BLAKE2b-256 |
e2a34aea8faf2617fc868649cd592e534e8e93ad4dbd09bf389f8b4bb9986b8d
|
File details
Details for the file confplot-0.1.1-py3-none-any.whl.
File metadata
- Download URL: confplot-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf476f102eb8edd73470bedc469ed52a1449c94ffe4c084287b7e5a618857aa6
|
|
| MD5 |
6497210c910541efe76e775697072966
|
|
| BLAKE2b-256 |
8949d45ceb0aa2061b15d3b143022f0669a30d33ba6bdcb38638be95f6e83f2c
|