Spaces:
Sleeping
Sleeping
Update app.py
Browse files247 unmodified lines248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297247 unmodified linesfrequency = determine_frequency(df)st.sidebar.write(f"Detected frequency: {frequency}")col1, col2 = st.columns([2,4])with col1:tab_insample, tab_forecast = st.tabs(["Input data", "Forecast"])with tab_insample:df_grid = df.drop(columns="unique_id")st.write(df_grid)# grid_table = AgGrid(# df_grid,# theme="alpine",# )with tab_forecast:df_grid = df.drop(columns="unique_id")# grid_table = AgGrid(# df_grid,# theme="alpine",# )with col2:# Load pre-trained modelsnhits_model, timesnet_model, lstm_model, tft_model = select_model_based_on_frequency(frequency, nhits_models, timesnet_models, lstm_models, tft_models)forecast_results = {}if st.sidebar.button("Submit"):start_time = time.time() # Start timingif model_choice == "NHITS":forecast_results['NHITS'] = generate_forecast(nhits_model, df)elif model_choice == "TimesNet":forecast_results['TimesNet'] = generate_forecast(timesnet_model, df)elif model_choice == "LSTM":forecast_results['LSTM'] = generate_forecast(lstm_model, df)elif model_choice == "TFT":forecast_results['TFT'] = generate_forecast(tft_model, df)for model_name, forecast_df in forecast_results.items():plot_forecasts(forecast_df, df, f'{model_name} Forecast for {y_col}')end_time = time.time() # End timingtime_taken = end_time - start_timest.success(f"Time taken for {model_choice} forecast: {time_taken:.2f} seconds")def dynamic_forecasting():247 unmodified lines248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296247 unmodified linesfrequency = determine_frequency(df)st.sidebar.write(f"Detected frequency: {frequency}")nhits_model, timesnet_model, lstm_model, tft_model = select_model_based_on_frequency(frequency, nhits_models, timesnet_models, lstm_models, tft_models)forecast_results = {}if st.sidebar.button("Submit"):start_time = time.time() # Start timingif model_choice == "NHITS":forecast_results['NHITS'] = generate_forecast(nhits_model, df)elif model_choice == "TimesNet":forecast_results['TimesNet'] = generate_forecast(timesnet_model, df)elif model_choice == "LSTM":forecast_results['LSTM'] = generate_forecast(lstm_model, df)elif model_choice == "TFT":forecast_results['TFT'] = generate_forecast(tft_model, df)for model_name, forecast_df in forecast_results.items():plot_forecasts(forecast_df, df, f'{model_name} Forecast for {y_col}')end_time = time.time() # End timingtime_taken = end_time - start_timest.success(f"Time taken for {model_choice} forecast: {time_taken:.2f} seconds")tab_insample, tab_forecast = st.tabs(["Input data", "Forecast"])with tab_insample:df_grid = df.drop(columns="unique_id")st.write(df_grid)# grid_table = AgGrid(# df_grid,# theme="alpine",# )with tab_forecast:df_grid = forecast_results[model_choice].drop(columns="unique_id")st.write(df_grid)# grid_table = AgGrid(# df_grid,# theme="alpine",# )def dynamic_forecasting():
app.py+40-41