conf-mat 1.1.0
Sophisticate Confusion Matrix
License: MIT
Requires Python: >=3.6
Keywords: confusion matrix

# conf-mat


[![PyPI version](https://badge.fury.io/py/conf-mat.svg)](https://badge.fury.io/py/conf-mat)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)


This library was created to address the confusion in confusion matrices and classification reports generated by libraries like scikit-learn. It displays confusion matrices and their heatmaps in a more aesthetically pleasing, intuitive way. It also presents classification reports and accuracy rates in a manner that clarifies the calculation method and how those results were obtained, which can help alleviate confusion for beginners in machine learning


## Installation


You can install `conf-mat` via pip:


```bash
pip install conf-mat
```


## Usage 


### For Binary Classification


```python
from numpy.random import randint
from matplotlib.pyplot import show
from conf_mat import print_conf_mat, plot_conf_mat, conf_mat_to_html


y_true = randint(0, 2, 1000)
y_pred = randint(0, 2, 1000)


# Show The Confusion Matrix On The Console (Classes Names Are Not Mandatory)
print_conf_mat(y_true, y_pred, classes_names=[False, True])


# Show The Confusion Matrix As A Heat Map (Classes Names Are Not Mandatory)
plot_conf_mat(y_true, y_pred, classes_names=[False, True])
show()  # If You Are Using VSCode And You Are Executing The Code Direcctely


# Show The Confusion Matrix As It Appears On The Console And As A Heat Map On The HTML Page (Classes Names Are Not Mandatory)
conf_mat_to_html(y_true, y_pred, classes_names=[False, True])
```


### Output


#### print_conf_mat Output


```bash
Confusion Matrix : 
________________

╒═════════════════════╤═══════════════════════════╤═══════════════════════════╕
│ Classes             │ Predicted Positive (PP)   │ Predicted Negative (PN)   │
╞═════════════════════╪═══════════════════════════╪═══════════════════════════╡
│ Actual Positive (P) │ True Positive (TP) : 240  │ False Negative (FN) : 241 │
│                     │                           │ Type II Error (Missed)    │
├─────────────────────┼───────────────────────────┼───────────────────────────┤
│ Actual Negative (N) │ False Positive (FP) : 259 │ True Negative (TN) : 260  │
│                     │ Type I Error (Wrong)      │                           │
╘═════════════════════╧═══════════════════════════╧═══════════════════════════╛

╒══════════╤═════════════════════════════════════════════════════╕
│          │ Rate (Score)                                        │
╞══════════╪═════════════════════════════════════════════════════╡
│ Accuracy │ Correct        TP + TN                              │
│          │ _______ : _________________  OR  1 - Error  =  0.5  │
│          │                                                     │
│          │  Total    TP + FP + FN + TN                         │
├──────────┼─────────────────────────────────────────────────────┤
│ Error    │ Wrong        FP + FN                                │
│          │ _____ : _________________  OR  1 - Accuracy  =  0.5 │
│          │                                                     │
│          │ Total   TP + FP + FN + TN                           │
╘══════════╧═════════════════════════════════════════════════════╛


Classification Report : 
_____________________

╒══════════════════╤═════════════════╤════════════════════╤═════════════════════╤════════════════╕
│                  │ Precision (P)   │ Recall (R)         │ F1-Score (F)        │ Support (S)    │
╞══════════════════╪═════════════════╪════════════════════╪═════════════════════╪════════════════╡
│ Positive (True)  │ P1 (PPV):       │ R1 (Sensitivity):  │ F1 :                │ S1 :           │
│                  │                 │                    │                     │                │
│                  │   TP            │   TP               │ 2 x P1 x R1         │                │
│                  │ _______  = 0.48 │ _______  = 0.5     │ ___________  = 0.49 │  TP + FN = 481 │
│                  │                 │                    │                     │                │
│                  │ TP + FP         │ TP + FN            │   P1 + R1           │                │
├──────────────────┼─────────────────┼────────────────────┼─────────────────────┼────────────────┤
│ Negative (False) │ P0 (NPV):       │ R0 (Specificity):  │ F0 :                │ S0 :           │
│                  │                 │                    │                     │                │
│                  │   TN            │   TN               │ 2 x P0 x R0         │                │
│                  │ _______  = 0.52 │ _______  = 0.5     │ ___________  = 0.51 │  FP + TN = 519 │
│                  │                 │                    │                     │                │
│                  │ TN + FN         │ TN + FP            │   P0 + R0           │                │
├──────────────────┼─────────────────┼────────────────────┼─────────────────────┼────────────────┤
│ Macro Avg        │ P1 + P0         │ R1 + R0            │ F1 + F0             │ TS = 1000      │
│                  │ _______  = 0.5  │ _______  = 0.5     │ _______  = 0.5      │                │
│                  │                 │                    │                     │                │
│                  │    2            │    2               │    2                │                │
├──────────────────┼─────────────────┼────────────────────┼─────────────────────┼────────────────┤
│ Weighted Avg     │ W1              │ W2                 │ W3                  │ TS = 1000      │
│                  │ __  = 0.5       │ __  = 0.5          │ __  = 0.5           │                │
│                  │                 │                    │                     │                │
│                  │ TS              │ TS                 │ TS                  │                │
╘══════════════════╧═════════════════╧════════════════════╧═════════════════════╧════════════════╛

PPV : Positive Predictive Value

NPV : Negative Predictive Value

W1 = (P1 x S1) + (P0 x S0)

W2 = (R1 x S1) + (R0 x S0)

W3 = (F1 x S1) + (F0 x S0)

TS : Total Support = S1 + S0

Note : All Real Numbers Are Rounded With Two Digits After The Comma
```


#### plot_conf_mat Output


https://drive.google.com/file/d/1IA3ke21FHXBx7hydamouMhS9zvjHcy9B/view?usp=drive_link


#### conf_mat_to_html Output


```bash
HTML File Generated Successfully :)
```
https://drive.google.com/file/d/1TBWlNjMJ89CtrrYRzDCBER97oc7d5xSs/view?usp=drive_link


#### You Can Plot, Generate HTML Page For Confusion Matrix And Classification Report Directly From One Calculation 


```python
from numpy.random import randint
from matplotlib.pyplot import show
from conf_mat import print_conf_mat, plot_conf_mat, conf_mat_to_html


y_true = randint(0, 2, 1000)
y_pred = randint(0, 2, 1000)


# Show The Confusion Matrix On The Console (Classes Names Are Not Mandatory)
cm = print_conf_mat(y_true, y_pred, classes_names=[False, True])


# Show The Confusion Matrix As A Heat Map (Classes Names Are Not Mandatory)
plot_conf_mat(conf_mat=cm, classes_names=[False, True])
show()  # If You Are Using VSCode And You Are Executing The Code Direcctely


# Show The Confusion Matrix As It Appears On The Console And As A Heat Map On The HTML Page (Classes Names Are Not Mandatory)
conf_mat_to_html(conf_mat=cm, classes_names=[False, True])
```


#### You Can Hide Detail Information For Confusion Matrix, Classification Report And Confusion Matrix Heatmap 


```python
from numpy.random import randint
from matplotlib.pyplot import show
from conf_mat import print_conf_mat, plot_conf_mat, conf_mat_to_html


y_true = randint(0, 2, 1000)
y_pred = randint(0, 2, 1000)


# Show The Confusion Matrix On The Console (Classes Names Are Not Mandatory)
cm = print_conf_mat(y_true, y_pred, classes_names=[False, True], detail=False)


# Show The Confusion Matrix As A Heat Map (Classes Names Are Not Mandatory)
plot_conf_mat(conf_mat=cm, classes_names=[False, True], detail=False)
show()  # If You Are Using VSCode And You Are Executing The Code Direcctely


# Show The Confusion Matrix As It Appears On The Console And As A Heat Map On The HTML Page (Classes Names Are Not Mandatory)
conf_mat_to_html(conf_mat=cm, classes_names=[False, True], detail=False)
```


### Output


#### print_conf_mat Output


```bash
Confusion Matrix : 
________________

╒═════════════════════╤═══════════════════════════╤═══════════════════════════╕
│ Classes             │   Predicted Positive (PP) │   Predicted Negative (PN) │
╞═════════════════════╪═══════════════════════════╪═══════════════════════════╡
│ Actual Positive (P) │                       239 │                       246 │
├─────────────────────┼───────────────────────────┼───────────────────────────┤
│ Actual Negative (N) │                       252 │                       263 │
╘═════════════════════╧═══════════════════════════╧═══════════════════════════╛

╒══════════╤════════════════╕
│          │   Rate (Score) │
╞══════════╪════════════════╡
│ Accuracy │            0.5 │
├──────────┼────────────────┤
│ Error    │            0.5 │
╘══════════╧════════════════╛


Classification Report : 
_____________________

╒══════════════════╤═════════════════╤══════════════╤════════════════╤═══════════════╕
│                  │   Precision (P) │   Recall (R) │   F1-Score (F) │   Support (S) │
╞══════════════════╪═════════════════╪══════════════╪════════════════╪═══════════════╡
│ Positive (True)  │            0.49 │         0.49 │           0.49 │           485 │
├──────────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ Negative (False) │            0.52 │         0.51 │           0.51 │           515 │
├──────────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ Macro Avg        │            0.5  │         0.5  │           0.5  │          1000 │
├──────────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ Weighted Avg     │            0.5  │         0.5  │           0.5  │          1000 │
╘══════════════════╧═════════════════╧══════════════╧════════════════╧═══════════════╛
```


#### plot_conf_mat Output


https://drive.google.com/file/d/1L42AslXk-JRHNYpzMLXoRhtuhVWkTibC/view?usp=drive_link


#### conf_mat_to_html Output


```bash
HTML File Generated Successfully :)
```
https://drive.google.com/file/d/1UqMaySEX2WFGF5rA0pmbQGAxGjs-icu5/view?usp=drive_link


#### You Can Plot And Generate HTML Page For Confusion Matrix Directly From One Calculation And Without Print Confusion Matrix And Classification Report


```python
from numpy.random import randint
from matplotlib.pyplot import show
from conf_mat import calc_conf_mat, plot_conf_mat, conf_mat_to_html


y_true = randint(0, 2, 1000)
y_pred = randint(0, 2, 1000)


# Show The Confusion Matrix On The Console (Classes Names Are Not Mandatory)
cm = calc_conf_mat(y_true, y_pred)
print(cm)

# Show The Confusion Matrix As A Heat Map (Classes Names Are Not Mandatory)
plot_conf_mat(conf_mat=cm, classes_names=[False, True], detail=False)
show()  # If You Are Using VSCode And You Are Executing The Code Direcctely


# Show The Confusion Matrix As It Appears On The Console And As A Heat Map On The HTML Page (Classes Names Are Not Mandcatory)
conf_mat_to_html(conf_mat=cm, classes_names=[False, True], detail=False)
```


### Output


#### calc_conf_mat Output


```bash
[[243, 242], [256, 259]]
```


#### plot_conf_mat Output


https://drive.google.com/file/d/1tLBhU1RIlIRFX5YR-nXJMljV_sOVm_SH/view?usp=drive_link


#### conf_mat_to_html Output


```bash
HTML File Generated Successfully :)
```
https://drive.google.com/file/d/1wkRWeC9yc_tuH_cnENXheAOSxTBVkMoG/view?usp=drive_link


### For Multi Classification


```python
from numpy.random import randint
from matplotlib.pyplot import show
from conf_mat import print_conf_mat, plot_conf_mat, conf_mat_to_html


y_true = randint(0, 10, 1000)
y_pred = randint(0, 10, 1000)


# Show The Confusion Matrix On The Console (Classes Names Are Not Mandatory)
print_conf_mat(y_true, y_pred, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'])


# Show The Confusion Matrix As A Heat Map (Classes Names Are Not Mandatory)
plot_conf_mat(y_true, y_pred, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'])
show()  # If You Are Using VSCode And You Are Executing The Code Direcctely


# Show The Confusion Matrix As It Appears On The Console And As A Heat Map On The HTML Page (Classes Names Are Not Mandatory)
conf_mat_to_html(y_true, y_pred, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'])
```


### Output


#### print_conf_mat Output


```bash
Confusion Matrix : 
________________

╒═══════════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤═══════╕
│ Classes   │   C1 │   C2 │   C3 │   C4 │   C5 │   C6 │   C7 │   C8 │   C9 │   C10 │
╞═══════════╪══════╪══════╪══════╪══════╪══════╪══════╪══════╪══════╪══════╪═══════╡
│ C1        │    8 │    9 │   10 │    7 │   13 │   10 │    9 │   12 │   15 │    11 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C2        │    9 │    6 │    5 │   15 │   10 │   15 │   13 │   10 │   12 │    10 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C3        │   14 │    5 │    8 │   10 │   17 │   10 │   10 │    6 │   17 │    12 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C4        │    8 │   10 │    3 │   11 │    7 │    7 │    9 │    8 │    7 │     7 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C5        │    5 │   13 │    7 │   11 │    8 │   13 │    7 │   10 │    6 │     8 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C6        │    9 │   12 │   13 │    9 │   14 │    9 │    8 │    8 │   13 │    10 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C7        │   14 │   11 │   11 │   20 │    6 │    6 │    9 │    9 │   10 │    10 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C8        │   10 │   13 │    8 │   12 │   12 │    6 │   10 │    5 │   12 │    14 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C9        │   12 │    9 │   13 │    9 │    9 │    8 │   11 │   11 │    9 │     9 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C10       │   12 │   13 │   11 │   12 │   10 │   14 │   11 │    4 │    6 │    11 │
╘═══════════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧═══════╛

Yellow  : Not None Correct Values / True Positive (TP) OR True Negative (TN)
Red     : Not None Wrong Values / False Positive (FP) OR False Negative (FN)
Green   : None Correct Values
Blue    : None Wrong Values

╒══════════╤═════════════════════════════════════════════════════════════════╕
│          │ Rate (Score)                                                    │
╞══════════╪═════════════════════════════════════════════════════════════════╡
│ Accuracy │ Correct      Sum Of Yellow Values                               │
│          │ _______ : ____________________________  OR  1 - Error  =  0.08  │
│          │                                                                 │
│          │  Total    Sum Of Yellow And Red Values                          │
├──────────┼─────────────────────────────────────────────────────────────────┤
│ Error    │ Wrong        Sum Of Red Values                                  │
│          │ _____ : ____________________________  OR  1 - Accuracy  =  0.92 │
│          │                                                                 │
│          │ Total   Sum Of Yellow And Red Values                            │
╘══════════╧═════════════════════════════════════════════════════════════════╛


Classification Report : 
_____________________

╒══════════════╤═════════════════╤══════════════╤════════════════╤═══════════════╕
│              │   Precision (P) │   Recall (R) │   F1-Score (F) │   Support (S) │
╞══════════════╪═════════════════╪══════════════╪════════════════╪═══════════════╡
│ C1           │            0.08 │         0.08 │           0.08 │           104 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C2           │            0.06 │         0.06 │           0.06 │           105 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C3           │            0.09 │         0.07 │           0.08 │           109 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C4           │            0.09 │         0.14 │           0.11 │            77 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C5           │            0.08 │         0.09 │           0.08 │            88 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C6           │            0.09 │         0.09 │           0.09 │           105 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C7           │            0.09 │         0.08 │           0.09 │           106 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C8           │            0.06 │         0.05 │           0.05 │           102 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C9           │            0.08 │         0.09 │           0.09 │           100 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C10          │            0.11 │         0.11 │           0.11 │           104 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ Macro Avg    │            0.08 │         0.09 │           0.08 │          1000 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ Weighted Avg │            0.08 │         0.08 │           0.08 │          1000 │
╘══════════════╧═════════════════╧══════════════╧════════════════╧═══════════════╛

Precision    : Yellow Value / Sum Of Yellow Value Column

Recall       : Yellow Value / Sum Of Yellow Value Row

F1-Score     : (2 x Precision x Recall) / (Precision + Recall)

Support      : Sum Of Each Row

Macro Avg    :

               Precision : (Sum Of Precision Column) / Classes Count

               Recall    : (Sum Of Recall Column) / Classes Count

               F1-Score  : (Sum Of F1-Score Column) / Classes Count

               Support   : Total (Sum Of All Matrix)

Weighted Avg :

               Precision : (Sum Of (Precision x support)) / Total (Sum Of All Matrix)

               Recall    : (Sum Of (Recall x Support)) / Total (Sum Of All Matrix)

               F1-Score  : (Sum Of (F1-Score x Support)) / Total (Sum Of All Matrix)

               Support   : Total (Sum Of All Matrix)

Note : All Real Numbers Are Rounded With Two Digits After The Comma
```


#### plot_conf_mat Output


https://drive.google.com/file/d/1Gp0CcqZwwZdb8ZTELzfKciJasFGNyqTc/view?usp=drive_link


#### conf_mat_to_html Output


```bash
HTML File Generated Successfully :)
```
https://drive.google.com/file/d/1hkxp1ewJ5yXV_Lr3Ba6Qopes5-Yc0chm/view?usp=drive_link


#### You Can Plot, Generate HTML Page For Confusion Matrix And Classification Report Directly From One Calculation 


```python
from numpy.random import randint
from matplotlib.pyplot import show
from conf_mat import print_conf_mat, plot_conf_mat, conf_mat_to_html


y_true = randint(0, 10, 1000)
y_pred = randint(0, 10, 1000)


# Show The Confusion Matrix On The Console (Classes Names Are Not Mandatory)
cm = print_conf_mat(y_true, y_pred, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'])


# Show The Confusion Matrix As A Heat Map (Classes Names Are Not Mandatory)
plot_conf_mat(conf_mat=cm, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'])
show()  # If You Are Using VSCode And You Are Executing The Code Direcctely


# Show The Confusion Matrix As It Appears On The Console And As A Heat Map On The HTML Page (Classes Names Are Not Mandatory)
conf_mat_to_html(conf_mat=cm, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'])
```


#### You Can Hide Detail Information For Confusion Matrix, Classification Report And Confusion Matrix Heatmap


```python
from numpy.random import randint
from matplotlib.pyplot import show
from conf_mat import print_conf_mat, plot_conf_mat, conf_mat_to_html


y_true = randint(0, 10, 1000)
y_pred = randint(0, 10, 1000)


# Show The Confusion Matrix On The Console (Classes Names Are Not Mandatory)
cm = print_conf_mat(y_true, y_pred, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'], detail=False)


# Show The Confusion Matrix As A Heat Map (Classes Names Are Not Mandatory)
plot_conf_mat(conf_mat=cm, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'], detail=False)
show()  # If You Are Using VSCode And You Are Executing The Code Direcctely


# Show The Confusion Matrix As It Appears On The Console And As A Heat Map On The HTML Page (Classes Names Are Not Mandatory)
conf_mat_to_html(conf_mat=cm, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'], detail=False)
```


### Output


#### print_conf_mat Output


```bash
Confusion Matrix : 
________________

╒═══════════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤═══════╕
│ Classes   │   C1 │   C2 │   C3 │   C4 │   C5 │   C6 │   C7 │   C8 │   C9 │   C10 │
╞═══════════╪══════╪══════╪══════╪══════╪══════╪══════╪══════╪══════╪══════╪═══════╡
│ C1        │   10 │    5 │   15 │    6 │    9 │   12 │   13 │    5 │   12 │    13 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C2        │   13 │    5 │    9 │    6 │   13 │   11 │   12 │    5 │    6 │    10 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C3        │   11 │   16 │    8 │   10 │   12 │   15 │    7 │   11 │   10 │    12 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C4        │   10 │    9 │   10 │    7 │   15 │   13 │   12 │   11 │   11 │    11 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C5        │   10 │    9 │   12 │    8 │   13 │    7 │    7 │    7 │    9 │     7 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C6        │   14 │   13 │   14 │   11 │    6 │   11 │    8 │   13 │   11 │    13 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C7        │    9 │   11 │   11 │    9 │    9 │   12 │    9 │   10 │    9 │     9 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C8        │   10 │   11 │   12 │   10 │    7 │   10 │   14 │   10 │   13 │    11 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C9        │    8 │   14 │    9 │    8 │    9 │    7 │    9 │   11 │    9 │    10 │
├───────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼───────┤
│ C10       │    8 │   10 │    7 │    4 │    8 │   13 │    8 │    6 │    9 │    13 │
╘═══════════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧═══════╛

╒══════════╤════════════════╕
│          │   Rate (Score) │
╞══════════╪════════════════╡
│ Accuracy │           0.1  │
├──────────┼────────────────┤
│ Error    │           0.91 │
╘══════════╧════════════════╛


Classification Report : 
_____________________

╒══════════════╤═════════════════╤══════════════╤════════════════╤═══════════════╕
│              │   Precision (P) │   Recall (R) │   F1-Score (F) │   Support (S) │
╞══════════════╪═════════════════╪══════════════╪════════════════╪═══════════════╡
│ C1           │            0.1  │         0.1  │           0.1  │           100 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C2           │            0.05 │         0.06 │           0.05 │            90 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C3           │            0.07 │         0.07 │           0.07 │           112 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C4           │            0.09 │         0.06 │           0.07 │           109 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C5           │            0.13 │         0.15 │           0.14 │            89 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C6           │            0.1  │         0.1  │           0.1  │           114 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C7           │            0.09 │         0.09 │           0.09 │            98 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C8           │            0.11 │         0.09 │           0.1  │           108 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C9           │            0.09 │         0.1  │           0.09 │            94 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ C10          │            0.12 │         0.15 │           0.13 │            86 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ Macro Avg    │            0.1  │         0.1  │           0.1  │          1000 │
├──────────────┼─────────────────┼──────────────┼────────────────┼───────────────┤
│ Weighted Avg │            0.09 │         0.1  │           0.09 │          1000 │
╘══════════════╧═════════════════╧══════════════╧════════════════╧═══════════════╛
```


#### plot_conf_mat Output


https://drive.google.com/file/d/1Card-dZs6sSjgqdiVPUMesXjy3u9nsuY/view?usp=drive_link


#### conf_mat_to_html Output


```bash
HTML File Generated Successfully :)
```
https://drive.google.com/file/d/14H1T4zzrqVR10f40OVD9wunqdcFjG1DU/view?usp=drive_link


#### You Can Plot And Generate HTML Page For Confusion Matrix Directly From One Calculation And Without Print Confusion Matrix And Classification Report


```python
from numpy.random import randint
from matplotlib.pyplot import show
from conf_mat import calc_conf_mat, plot_conf_mat, conf_mat_to_html


y_true = randint(0, 10, 1000)
y_pred = randint(0, 10, 1000)


# Show The Confusion Matrix On The Console (Classes Names Are Not Mandatory)
cm = calc_conf_mat(y_true, y_pred)
print(cm)

# Show The Confusion Matrix As A Heat Map (Classes Names Are Not Mandatory)
plot_conf_mat(conf_mat=cm, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'], detail=False)
show()  # If You Are Using VSCode And You Are Executing The Code Direcctely


# Show The Confusion Matrix As It Appears On The Console And As A Heat Map On The HTML Page (Classes Names Are Not Mandatory)
conf_mat_to_html(conf_mat=cm, classes_names=[
    'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10'], detail=False)
```


### Output


#### calc_conf_mat Output


```bash
[[16, 11, 8, 6, 4, 11, 12, 9, 10, 6], [12, 15, 14, 7, 20, 7, 17, 8, 6, 10], [13, 13, 11, 12, 11, 10, 11, 9, 8, 9], [12, 11, 5, 15, 9, 10, 8, 10, 13, 9], [8, 13, 11, 8, 8, 8, 12, 15, 7, 12], [13, 8, 17, 14, 8, 7, 10, 6, 8, 6], [7, 21, 7, 7, 10, 11, 10, 12, 11, 8], [9, 10, 15, 11, 7, 6, 9, 6, 9, 9], [9, 13, 7, 14, 7, 10, 5, 11, 5, 7], [13, 9, 11, 8, 12, 12, 9, 7, 6, 13]]
```


#### plot_conf_mat Output


https://drive.google.com/file/d/1wmH3jQj8WZKtf2Vr-7LQgkI1udDFm0Zj/view?usp=drive_link


#### conf_mat_to_html Output


```bash
HTML File Generated Successfully :)
```
https://drive.google.com/file/d/104P1o4tQPZGvZo5UlYdm6vZAfjrBCcHI/view?usp=drive_link


### Note


You can import all functions with the camelCase format in place of snake_case format.


## License


This project is licensed under the MIT LICENSE - see the [LICENSE](https://opensource.org/licenses/MIT) for more details.