Sandeep S commited on
Commit ·
28be6db
1
Parent(s): 2247df3
Added Brier Score and SHAP analysis
Browse files- graphs/SHAP_Summary.png +0 -0
- main.py +13 -2
graphs/SHAP_Summary.png
ADDED
|
main.py
CHANGED
|
@@ -2,9 +2,12 @@ import pandas as pd
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import seaborn as sns
|
| 4 |
from sklearn.linear_model import LogisticRegression
|
| 5 |
-
from sklearn.metrics import classification_report, confusion_matrix, accuracy_score, roc_auc_score, ConfusionMatrixDisplay
|
| 6 |
from sklearn.preprocessing import LabelEncoder, StandardScaler
|
| 7 |
from sklearn.model_selection import train_test_split
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
dataset = pd.read_csv("data.csv")
|
| 10 |
|
|
@@ -62,7 +65,15 @@ display = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=model.class
|
|
| 62 |
display.plot(cmap=plt.cm.Blues)
|
| 63 |
plt.savefig("graphs/ConfusionMatrix.png")
|
| 64 |
|
|
|
|
|
|
|
| 65 |
print("Accuracy Score:")
|
| 66 |
print(accuracy_score(y_test, y_pred))
|
| 67 |
print("ROC AUC Score:")
|
| 68 |
-
print(roc_auc_score(y_test, y_pred))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import seaborn as sns
|
| 4 |
from sklearn.linear_model import LogisticRegression
|
| 5 |
+
from sklearn.metrics import classification_report, confusion_matrix, accuracy_score, roc_auc_score, ConfusionMatrixDisplay, brier_score_loss
|
| 6 |
from sklearn.preprocessing import LabelEncoder, StandardScaler
|
| 7 |
from sklearn.model_selection import train_test_split
|
| 8 |
+
import shap
|
| 9 |
+
|
| 10 |
+
shap.initjs()
|
| 11 |
|
| 12 |
dataset = pd.read_csv("data.csv")
|
| 13 |
|
|
|
|
| 65 |
display.plot(cmap=plt.cm.Blues)
|
| 66 |
plt.savefig("graphs/ConfusionMatrix.png")
|
| 67 |
|
| 68 |
+
print("Brier Score Loss:")
|
| 69 |
+
print(brier_score_loss(y_test, y_pred))
|
| 70 |
print("Accuracy Score:")
|
| 71 |
print(accuracy_score(y_test, y_pred))
|
| 72 |
print("ROC AUC Score:")
|
| 73 |
+
print(roc_auc_score(y_test, y_pred))
|
| 74 |
+
|
| 75 |
+
# SHAP Analysis
|
| 76 |
+
explainer = shap.LinearExplainer(model, X_train)
|
| 77 |
+
shap_values = explainer(X_test)
|
| 78 |
+
shap.summary_plot(shap_values, X_test, plot_type="bar", show=False)
|
| 79 |
+
plt.savefig("graphs/SHAP_Summary.png")
|