Datasets:
Commit
·
a61f6bb
1
Parent(s):
18f8bf5
modify scripts
Browse files- scripts/model_analysis.py +3 -3
- scripts/model_constrcution.py +0 -33
scripts/model_analysis.py
CHANGED
|
@@ -26,9 +26,9 @@ feature_cols = x_train.columns.tolist()
|
|
| 26 |
|
| 27 |
###Reload the model
|
| 28 |
from h2o import load_model
|
| 29 |
-
restored_model1 = h2o.load_model("
|
| 30 |
-
restored_model2 = h2o.load_model("
|
| 31 |
-
restored_model3 = h2o.load_model("
|
| 32 |
|
| 33 |
###Test the model
|
| 34 |
perf1=restored_model1.model_performance(test_h2o)
|
|
|
|
| 26 |
|
| 27 |
###Reload the model
|
| 28 |
from h2o import load_model
|
| 29 |
+
restored_model1 = h2o.load_model("./product/top_model_1/StackedEnsemble_AllModels_1_AutoML_1_20250401_220205")
|
| 30 |
+
restored_model2 = h2o.load_model("./product/top_model_2/StackedEnsemble_BestOfFamily_1_AutoML_1_20250401_220205")
|
| 31 |
+
restored_model3 = h2o.load_model("./product/top_model_3/GBM_4_AutoML_1_20250401_220205")
|
| 32 |
|
| 33 |
###Test the model
|
| 34 |
perf1=restored_model1.model_performance(test_h2o)
|
scripts/model_constrcution.py
CHANGED
|
@@ -52,36 +52,3 @@ for model_id in model_ids:
|
|
| 52 |
|
| 53 |
cv_all_models_df = pd.concat(all_model_summaries, ignore_index=True)
|
| 54 |
cv_all_models_df.to_csv("./intermediate/cross_validation_result.csv",index=False)
|
| 55 |
-
|
| 56 |
-
###Reload the model for addtional test
|
| 57 |
-
from h2o import load_model
|
| 58 |
-
restored_model1 = h2o.load_model("./product/top_model_1/StackedEnsemble_AllModels_1_AutoML_1_20250401_220205")
|
| 59 |
-
restored_model2 = h2o.load_model("./product/top_model_2/StackedEnsemble_BestOfFamily_1_AutoML_1_20250401_220205")
|
| 60 |
-
restored_model3 = h2o.load_model("./product/top_model_3/GBM_4_AutoML_1_20250401_220205")
|
| 61 |
-
|
| 62 |
-
perf1=restored_model1.model_performance(test_h2o)
|
| 63 |
-
perf2=restored_model2.model_performance(test_h2o)
|
| 64 |
-
perf3=restored_model3.model_performance(test_h2o)
|
| 65 |
-
|
| 66 |
-
###Obtain the performance
|
| 67 |
-
threshold = 0.5
|
| 68 |
-
acc = perf1.accuracy(thresholds=[threshold])[0][1]
|
| 69 |
-
f1 = perf1.F1(thresholds=[threshold])[0][1]
|
| 70 |
-
prec = perf1.precision(thresholds=[threshold])[0][1]
|
| 71 |
-
rec = perf1.recall(thresholds=[threshold])[0][1]
|
| 72 |
-
spec = perf1.specificity(thresholds=[threshold])[0][1]
|
| 73 |
-
AUC= perf1.auc()
|
| 74 |
-
LogLoss=perf1.logloss()
|
| 75 |
-
print(f"AUC = {AUC}")
|
| 76 |
-
print(f"LogLoss = {LogLoss}")
|
| 77 |
-
print(f"Threshold = {threshold}")
|
| 78 |
-
print(f"Accuracy = {acc:.4f}")
|
| 79 |
-
print(f"F1 Score = {f1:.4f}")
|
| 80 |
-
print(f"Precision = {prec:.4f}")
|
| 81 |
-
print(f"Recall = {rec:.4f}")
|
| 82 |
-
print(f"Specificity = {spec:.4f}")
|
| 83 |
-
|
| 84 |
-
###SHAP analysis for the third-best model
|
| 85 |
-
restored_model3.shap_summary_plot(test_h2o[:,:-1])
|
| 86 |
-
fig = plt.gcf()
|
| 87 |
-
fig.savefig("./product/3shap_summary_plot.png", dpi=300, bbox_inches="tight")
|
|
|
|
| 52 |
|
| 53 |
cv_all_models_df = pd.concat(all_model_summaries, ignore_index=True)
|
| 54 |
cv_all_models_df.to_csv("./intermediate/cross_validation_result.csv",index=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|