Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fcakyon/confplot
Confusion Matrix in Python: Plot a pretty confusion matrix (like Matlab) in python using seaborn and matplotlib
https://github.com/fcakyon/confplot
confusion-matrix confusionmatrix linux macos matlab matplotlib package pip plot pypi python seaborn windows
Last synced: 16 days ago
JSON representation
Confusion Matrix in Python: Plot a pretty confusion matrix (like Matlab) in python using seaborn and matplotlib
- Host: GitHub
- URL: https://github.com/fcakyon/confplot
- Owner: fcakyon
- License: apache-2.0
- Created: 2020-05-25T14:50:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-18T08:24:27.000Z (over 4 years ago)
- Last Synced: 2024-12-27T05:10:57.948Z (26 days ago)
- Topics: confusion-matrix, confusionmatrix, linux, macos, matlab, matplotlib, package, pip, plot, pypi, python, seaborn, windows
- Language: Python
- Size: 269 KB
- Stars: 11
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ConfPlot: Plot Confusion Matrix in Python
[![Downloads](https://pepy.tech/badge/confplot)](https://pepy.tech/project/confplot)
[![PyPI version](https://badge.fury.io/py/confplot.svg)](https://badge.fury.io/py/confplot)
![CI](https://github.com/fcakyon/confplot/workflows/CI/badge.svg)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
```console
pip install confplot
```### Usage
#### Plot confusion matrix from matrix
```python
# 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
```python
# 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"
)
```