Update src/streamlit_app.py
Browse files- src/streamlit_app.py +9 -3
src/streamlit_app.py
CHANGED
|
@@ -42,13 +42,19 @@ ENSEMBLE_PATH = os.path.join(LOG_DIR, "ensemble_models.joblib")
|
|
| 42 |
LOG_PATH = os.path.join(LOG_DIR, "run_master.log")
|
| 43 |
|
| 44 |
# Simple logger that time-stamps inside one file
|
|
|
|
|
|
|
| 45 |
def log(msg: str):
|
|
|
|
| 46 |
stamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 47 |
with open(LOG_PATH, "a", encoding="utf-8") as f:
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
f.write(f"[{stamp}] {msg}\n")
|
| 50 |
print(msg)
|
| 51 |
|
|
|
|
| 52 |
log("=== Streamlit session started ===")
|
| 53 |
|
| 54 |
|
|
@@ -799,7 +805,7 @@ with tabs[4]:
|
|
| 799 |
|
| 800 |
# Final evaluation
|
| 801 |
final_r2 = r2_score(y_val, y_meta_pred)
|
| 802 |
-
final_rmse = mean_squared_error(y_val, y_meta_pred
|
| 803 |
st.success("AutoML + Stacking complete — metrics, artifacts, and SHAP ready.")
|
| 804 |
log(f"Completed stacking. Final R2={final_r2:.4f}, RMSE={final_rmse:.4f}")
|
| 805 |
|
|
@@ -947,7 +953,7 @@ st.markdown("**Notes:** This dataset is synthetic and for demo/prototyping. Real
|
|
| 947 |
|
| 948 |
|
| 949 |
# ----- Download tab
|
| 950 |
-
with tabs[-
|
| 951 |
st.subheader(" Download Saved Files (Flat Log Mode)")
|
| 952 |
|
| 953 |
available_files = [f for f in os.listdir(LOG_DIR) if os.path.isfile(os.path.join(LOG_DIR, f))]
|
|
|
|
| 42 |
LOG_PATH = os.path.join(LOG_DIR, "run_master.log")
|
| 43 |
|
| 44 |
# Simple logger that time-stamps inside one file
|
| 45 |
+
SESSION_STARTED = False
|
| 46 |
+
|
| 47 |
def log(msg: str):
|
| 48 |
+
global SESSION_STARTED
|
| 49 |
stamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 50 |
with open(LOG_PATH, "a", encoding="utf-8") as f:
|
| 51 |
+
if not SESSION_STARTED:
|
| 52 |
+
f.write("\n\n===== New Session Started at {} =====\n".format(stamp))
|
| 53 |
+
SESSION_STARTED = True
|
| 54 |
f.write(f"[{stamp}] {msg}\n")
|
| 55 |
print(msg)
|
| 56 |
|
| 57 |
+
|
| 58 |
log("=== Streamlit session started ===")
|
| 59 |
|
| 60 |
|
|
|
|
| 805 |
|
| 806 |
# Final evaluation
|
| 807 |
final_r2 = r2_score(y_val, y_meta_pred)
|
| 808 |
+
final_rmse = float(np.sqrt(mean_squared_error(y_val, y_meta_pred)))
|
| 809 |
st.success("AutoML + Stacking complete — metrics, artifacts, and SHAP ready.")
|
| 810 |
log(f"Completed stacking. Final R2={final_r2:.4f}, RMSE={final_rmse:.4f}")
|
| 811 |
|
|
|
|
| 953 |
|
| 954 |
|
| 955 |
# ----- Download tab
|
| 956 |
+
with tabs[-2]:
|
| 957 |
st.subheader(" Download Saved Files (Flat Log Mode)")
|
| 958 |
|
| 959 |
available_files = [f for f in os.listdir(LOG_DIR) if os.path.isfile(os.path.join(LOG_DIR, f))]
|