conf-mat
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:
pip install conf-mat
Usage
For Binary Classification
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
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
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
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
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
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
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
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
[[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
HTML File Generated Successfully :)
https://drive.google.com/file/d/1wkRWeC9yc_tuH_cnENXheAOSxTBVkMoG/view?usp=drive_link
For Multi Classification
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
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
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
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
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
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
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
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
[[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
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 for more details.
Metadata
Release files for conf-mat 1.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 | Provenance | Actions |
|---|---|---|---|---|
| conf-mat-1.1.0.tar.gz | 284.9 kB | Without provenance | Details for conf-mat-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| conf_mat-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for conf_mat-1.1.0-py3-none-any.whl |
Total release size: 561.2 kB
Release files / conf-mat-1.1.0.tar.gz
| Download URL | conf-mat-1.1.0.tar.gz |
|---|---|
| Size | 284.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
356e0af8b783ebb7fa6aae42348aaae497ce6d8618fa091b4cf0bdb47dd81503
|
|
BLAKE2b-256 checksum How to use checksums |
599d758966de03910000e13c28bb0cd98189b82e0612fce6d53de04191b84bcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.2
|
Release files / conf_mat-1.1.0-py3-none-any.whl
| Download URL | conf_mat-1.1.0-py3-none-any.whl |
|---|---|
| Size | 276.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b624d331c5559c4bbe4f3d73b2dcdc2564d9557e9fb0f5f68d59e315b2c3c07
|
|
BLAKE2b-256 checksum How to use checksums |
1970f36bbae15f914fedcbc0ce26650184d50236e3f3a855f8be8eed97469f2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.2
|
Security for conf-mat 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.