mcshoja commited on
Commit
fa152ff
·
verified ·
1 Parent(s): 115d24f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +24 -17
src/streamlit_app.py CHANGED
@@ -130,28 +130,35 @@ if page == "National Situation":
130
  col3.metric("Forecast Projection", forecast_month.strftime("%B %Y"))
131
 
132
  # Trend
133
- fig = go.Figure()
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  fig.add_trace(go.Scatter(
136
- x=national["month"],
137
- y=national["risk_proba"],
138
- mode="lines",
139
- name="Historical"
 
140
  ))
141
 
142
- if not forecast.empty:
143
- fig.add_trace(go.Scatter(
144
- x=[forecast_month],
145
- y=[forecast["risk_proba"].mean()],
146
- mode="lines+markers",
147
- line=dict(dash="dash"),
148
- name="Projection"
149
- ))
150
-
151
- fig.add_hline(y=threshold, line_dash="dot")
152
- fig.update_layout(height=400)
153
 
154
- st.plotly_chart(fig, use_container_width=True)
155
 
156
  st.subheader("Top Risk Counties")
157
  top_current = latest_data.sort_values("risk_proba", ascending=False).head(10)
 
130
  col3.metric("Forecast Projection", forecast_month.strftime("%B %Y"))
131
 
132
  # Trend
133
+ fig = go.Figure()
134
 
135
+ # Ensure month column exists
136
+ if "month" not in national.columns:
137
+ national = national.rename(columns={"Month": "month"})
138
+
139
+ national["month"] = pd.to_datetime(national["month"])
140
+
141
+ fig.add_trace(go.Scatter(
142
+ x=national["month"],
143
+ y=national["national_avg_risk"],
144
+ mode="lines",
145
+ name="Historical"
146
+ ))
147
+
148
+ # Forecast projection (mean of forecast file)
149
+ if not forecast.empty and "risk_proba" in forecast.columns:
150
  fig.add_trace(go.Scatter(
151
+ x=[forecast_month],
152
+ y=[forecast["risk_proba"].mean()],
153
+ mode="lines+markers",
154
+ line=dict(dash="dash"),
155
+ name="Projection"
156
  ))
157
 
158
+ fig.add_hline(y=threshold, line_dash="dot")
159
+ fig.update_layout(height=400)
 
 
 
 
 
 
 
 
 
160
 
161
+ st.plotly_chart(fig, use_container_width=True)
162
 
163
  st.subheader("Top Risk Counties")
164
  top_current = latest_data.sort_values("risk_proba", ascending=False).head(10)