Pranav216 commited on
Commit
cd7f163
Β·
1 Parent(s): fd3b379

Graphs restructred

Browse files
frontend.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import gradio as gr
2
+ from main import
graphs/{Churn.png β†’ EDAGraphs/Churn.png} RENAMED
File without changes
graphs/{Contract.png β†’ EDAGraphs/Contract.png} RENAMED
File without changes
graphs/{Correlation.png β†’ EDAGraphs/Correlation.png} RENAMED
File without changes
graphs/{Dependents.png β†’ EDAGraphs/Dependents.png} RENAMED
File without changes
graphs/{DeviceProtection.png β†’ EDAGraphs/DeviceProtection.png} RENAMED
File without changes
graphs/{MonthlyCharges.png β†’ EDAGraphs/MonthlyCharges.png} RENAMED
File without changes
graphs/{OnlineBackup.png β†’ EDAGraphs/OnlineBackup.png} RENAMED
File without changes
graphs/{OnlineSecurity.png β†’ EDAGraphs/OnlineSecurity.png} RENAMED
File without changes
graphs/{PaperlessBilling.png β†’ EDAGraphs/PaperlessBilling.png} RENAMED
File without changes
graphs/{Partner.png β†’ EDAGraphs/Partner.png} RENAMED
File without changes
graphs/{PaymentMethod.png β†’ EDAGraphs/PaymentMethod.png} RENAMED
File without changes
graphs/{SeniorCitizen.png β†’ EDAGraphs/SeniorCitizen.png} RENAMED
File without changes
graphs/{TechSupport.png β†’ EDAGraphs/TechSupport.png} RENAMED
File without changes
graphs/{tenure.png β†’ EDAGraphs/tenure.png} RENAMED
File without changes
graphs/{ConfusionMatrix.png β†’ OutputGraphs/ConfusionMatrixLogistic.png} RENAMED
File without changes
graphs/OutputGraphs/ConfusionMatrixRandomForest.png ADDED
graphs/{SHAP_Logistic_Summary.png β†’ OutputGraphs/SHAP_Logistic_Summary.png} RENAMED
File without changes
graphs/OutputGraphs/SHAP_RandomForest_Summary.png ADDED
graphs/SHAP_RandomForest_Summary.png DELETED
Binary file (42.1 kB)
 
main.py CHANGED
@@ -33,19 +33,19 @@ corr=dataset.corr()["Churn"]
33
  ax.set_xticklabels(corr.index, rotation=45, ha='right', fontsize=10)
34
 
35
  sns.barplot(x=corr.index, y=corr.values, ax=ax)
36
- plt.savefig("graphs/Correlation.png")
37
 
38
  # Based on the correlation plot, the following features are removed
39
  dataset.drop(columns=['gender', 'PhoneService', 'MultipleLines', 'InternetService', 'StreamingTV', 'StreamingMovies', 'TotalCharges'], inplace=True)
40
  # Multivariate analysis
41
  fig, ax = plt.subplots(figsize=(16, 10))
42
  sns.heatmap(dataset.corr(), annot=True, fmt=".2f", cmap='coolwarm', ax=ax)
43
- plt.savefig("graphs/Heatmap.png")
44
 
45
  for column in dataset.columns:
46
  fig, ax = plt.subplots(figsize=(16, 10))
47
  sns.kdeplot(dataset[column],ax=ax)
48
- plt.savefig(f"graphs/{column}.png")
49
 
50
  # Splitting the dataset into training and testing sets
51
  y = dataset.pop("Churn").values
@@ -68,7 +68,7 @@ cm = confusion_matrix(y_test, y_rf_pred)
68
 
69
  display = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=rf_clf.classes_)
70
  display.plot(cmap=plt.cm.Blues)
71
- plt.savefig("graphs/ConfusionMatrix.png")
72
 
73
  print("Brier Score Loss:")
74
  print(brier_score_loss(y_test, y_rf_pred))
@@ -81,7 +81,7 @@ print(roc_auc_score(y_test, y_rf_pred))
81
  explainer = shap.TreeExplainer(rf_clf)
82
  shap_values = explainer.shap_values(X_test)
83
  shap.summary_plot(shap_values, X_test, plot_type="bar", show=False)
84
- plt.savefig("graphs/SHAP_RandomForest_Summary.png")
85
 
86
 
87
  # Logistic Regression Model
@@ -100,7 +100,7 @@ cm = confusion_matrix(y_test, y_log_pred)
100
 
101
  display = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=logistic.classes_)
102
  display.plot(cmap=plt.cm.Blues)
103
- plt.savefig("graphs/ConfusionMatrix.png")
104
 
105
  print("Brier Score Loss:")
106
  print(brier_score_loss(y_test, y_log_pred))
@@ -113,4 +113,4 @@ print(roc_auc_score(y_test, y_log_pred))
113
  explainer = shap.LinearExplainer(logistic, X_train)
114
  shap_values = explainer(X_test)
115
  shap.summary_plot(shap_values, X_test, plot_type="bar", show=False)
116
- plt.savefig("graphs/SHAP_Logistic_Summary.png")
 
33
  ax.set_xticklabels(corr.index, rotation=45, ha='right', fontsize=10)
34
 
35
  sns.barplot(x=corr.index, y=corr.values, ax=ax)
36
+ plt.savefig("graphs/EDAGraphs/Correlation.png")
37
 
38
  # Based on the correlation plot, the following features are removed
39
  dataset.drop(columns=['gender', 'PhoneService', 'MultipleLines', 'InternetService', 'StreamingTV', 'StreamingMovies', 'TotalCharges'], inplace=True)
40
  # Multivariate analysis
41
  fig, ax = plt.subplots(figsize=(16, 10))
42
  sns.heatmap(dataset.corr(), annot=True, fmt=".2f", cmap='coolwarm', ax=ax)
43
+ plt.savefig("graphs/EDAGraphs/Heatmap.png")
44
 
45
  for column in dataset.columns:
46
  fig, ax = plt.subplots(figsize=(16, 10))
47
  sns.kdeplot(dataset[column],ax=ax)
48
+ plt.savefig(f"graphs/EDAGraphs/{column}.png")
49
 
50
  # Splitting the dataset into training and testing sets
51
  y = dataset.pop("Churn").values
 
68
 
69
  display = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=rf_clf.classes_)
70
  display.plot(cmap=plt.cm.Blues)
71
+ plt.savefig("graphs/OutputGraphs/ConfusionMatrixRandomForest.png")
72
 
73
  print("Brier Score Loss:")
74
  print(brier_score_loss(y_test, y_rf_pred))
 
81
  explainer = shap.TreeExplainer(rf_clf)
82
  shap_values = explainer.shap_values(X_test)
83
  shap.summary_plot(shap_values, X_test, plot_type="bar", show=False)
84
+ plt.savefig("graphs/OutputGraphs/SHAP_RandomForest_Summary.png")
85
 
86
 
87
  # Logistic Regression Model
 
100
 
101
  display = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=logistic.classes_)
102
  display.plot(cmap=plt.cm.Blues)
103
+ plt.savefig("graphs/OutputGraphs/ConfusionMatrixLogistic.png")
104
 
105
  print("Brier Score Loss:")
106
  print(brier_score_loss(y_test, y_log_pred))
 
113
  explainer = shap.LinearExplainer(logistic, X_train)
114
  shap_values = explainer(X_test)
115
  shap.summary_plot(shap_values, X_test, plot_type="bar", show=False)
116
+ plt.savefig("graphs/OutputGraphs/SHAP_Logistic_Summary.png")