add cm plot
This commit is contained in:
@@ -2,7 +2,7 @@ import pandas as pd
|
|||||||
from sklearn.model_selection import train_test_split
|
from sklearn.model_selection import train_test_split
|
||||||
from sklearn.linear_model import LogisticRegression
|
from sklearn.linear_model import LogisticRegression
|
||||||
from sklearn.preprocessing import LabelEncoder
|
from sklearn.preprocessing import LabelEncoder
|
||||||
from sklearn.metrics import accuracy_score, classification_report
|
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix
|
||||||
import pickle
|
import pickle
|
||||||
import statsmodels.api as sm
|
import statsmodels.api as sm
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
@@ -38,6 +38,18 @@ accuracy = accuracy_score(y_test, y_pred)
|
|||||||
classification_report_result = classification_report(y_test, y_pred)
|
classification_report_result = classification_report(y_test, y_pred)
|
||||||
#sns.heatmap(pd.DataFrame(classification_report_result).iloc[:-1, :].T, annot=True)
|
#sns.heatmap(pd.DataFrame(classification_report_result).iloc[:-1, :].T, annot=True)
|
||||||
|
|
||||||
|
|
||||||
|
# Calculate the confusion matrix
|
||||||
|
confusion = confusion_matrix(y_test, y_pred)
|
||||||
|
|
||||||
|
# Plot the confusion matrix using Seaborn
|
||||||
|
plt.figure(figsize=(8, 6))
|
||||||
|
sns.heatmap(confusion, annot=True, fmt='d', cmap='Blues', linewidths=0.5)
|
||||||
|
plt.xlabel('Predicted')
|
||||||
|
plt.ylabel('Actual')
|
||||||
|
plt.title('Confusion Matrix')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
print(f"Accuracy: {accuracy}")
|
print(f"Accuracy: {accuracy}")
|
||||||
print("Classification Report:")
|
print("Classification Report:")
|
||||||
print(classification_report_result)
|
print(classification_report_result)
|
||||||
|
|||||||
Reference in New Issue
Block a user