77import streamlit as st
88
99from utils import ui , viz
10+ from utils import time_series as ts
1011from utils .logging import configure_logging
1112
1213configure_logging ()
@@ -38,6 +39,12 @@ def main() -> None:
3839 period = st .number_input (
3940 "Seasonal Period" , min_value = 2 , value = 2 , step = 1 , key = "ts_period"
4041 )
42+ model_choice = st .selectbox (
43+ "Forecast Model" , ["Naive" , "ARIMA" ], key = "ts_model"
44+ )
45+ horizon = st .number_input (
46+ "Forecast Horizon" , min_value = 1 , value = 5 , step = 1 , key = "ts_horizon"
47+ )
4148
4249 if st .button ("Generate Plots" ):
4350 ts_fig = viz .time_series_plot (df , time_col , value_col , title = "Time Series" )
@@ -52,6 +59,20 @@ def main() -> None:
5259 mime = f"image/{ export_fmt } " ,
5360 )
5461
62+ series = df .set_index (time_col )[value_col ]
63+ if model_choice == "ARIMA" :
64+ try :
65+ forecast = ts .arima_forecast (series , steps = horizon )
66+ except ImportError :
67+ st .error ("statsmodels is required for ARIMA forecasting." )
68+ forecast = None
69+ else :
70+ forecast = ts .naive_forecast (series , steps = horizon )
71+
72+ if forecast is not None :
73+ st .subheader ("Forecast" )
74+ st .write (forecast .to_frame (name = "forecast" ))
75+
5576 dec_fig = viz .decomposition_plot (
5677 df .set_index (time_col )[value_col ], period = period , title = "Decomposition"
5778 )
0 commit comments