MCPcopy Create free account
hub / github.com/Hrishikesh332/HCDS-EPD / forecasting

Function forecasting

nav/forecasting.py:7–31  ·  view source on GitHub ↗
(df)

Source from the content-addressed store, hash-verified

5from config import create_region_selector
6
7def forecasting(df):
8 st.markdown('<h1 class="main-header">Forecast</h1>', unsafe_allow_html=True)
9
10 selected_region = create_region_selector(df)
11 region_data = df[df['REGIONAL_OFFICE_NAME'] == selected_region]
12 available_categories = sorted(region_data['BNF_CHAPTER_PLUS_CODE'].unique())
13 default_categories = available_categories[:8] if len(available_categories) > 8 else available_categories
14 selected_categories = st.multiselect(
15 "Choose Categories:",
16 available_categories,
17 default=default_categories
18 )
19
20 col1, _ = st.columns(2)
21 with col1:
22 forecast_periods = st.slider("Months to Forecast:", 1, 12, 3)
23
24 if not selected_categories:
25 st.warning("Select at least one category.")
26 return
27
28 line_chart = create_multi_category_forecast(region_data, selected_categories, forecast_periods)
29 st.plotly_chart(line_chart, use_container_width=True)
30
31 forecast_insights(region_data, selected_categories, forecast_periods)
32
33def create_multi_category_forecast(region_data, selected_categories, forecast_months):
34 all_bnf = region_data.groupby('BNF_CHAPTER_PLUS_CODE')['TOTAL_COST'].sum()

Callers 1

route_to_pageFunction · 0.90

Calls 3

create_region_selectorFunction · 0.90
forecast_insightsFunction · 0.85

Tested by

no test coverage detected