azrai99 commited on
Commit
c65f546
·
verified ·
1 Parent(s): 67e7e14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -311,7 +311,7 @@ def transfer_learning_forecasting():
311
 
312
 
313
  def dynamic_forecasting():
314
- st.title("Dynamic Forecasting")
315
  st.markdown("""
316
  Train time series forecasting model from scratch and provide forecasts/visualization by using various deep neural network-based model trained on user data.
317
 
@@ -414,8 +414,9 @@ def timegpt_fcst():
414
 
415
  df = df.drop_duplicates(subset=['ds']).reset_index(drop=True)
416
 
417
- # st.write(df)
418
  if st.sidebar.button("Submit"):
 
419
  forecast_df = nixtla_client.forecast(
420
  df=df,
421
  h=h,
@@ -424,9 +425,14 @@ def timegpt_fcst():
424
  )
425
  st.session_state.forecast_df = forecast_df
426
 
427
- if 'forecast_df' in st.session_state:
428
- forecast_df = st.session_state.forecast_df
429
- st.pyplot(nixtla_client.plot(df, forecast_df, level=[90]))
 
 
 
 
 
430
 
431
 
432
 
@@ -478,6 +484,7 @@ def timegpt_anom():
478
 
479
  df = df.drop_duplicates(subset=['ds']).reset_index(drop=True)
480
  if st.sidebar.button("Submit"):
 
481
  anom_df = nixtla_client.detect_anomalies(
482
  df=df,
483
  freq=freq,
@@ -485,9 +492,13 @@ def timegpt_anom():
485
  )
486
  st.session_state.anom_df = anom_df
487
 
488
- if 'anom_df' in st.session_state:
489
- anom_df = st.session_state.anom_df
490
- st.pyplot(nixtla_client.plot(df, anom_df))
 
 
 
 
491
 
492
 
493
 
@@ -497,7 +508,7 @@ pg = st.navigation({
497
  "Neuralforecast": [
498
  # Load pages from functions
499
  st.Page(transfer_learning_forecasting, title="Zero-shot Forecasting", default=True, icon=":material/query_stats:"),
500
- st.Page(dynamic_forecasting, title="Dynamic Forecasting", icon=":material/monitoring:"),
501
  ],
502
  "TimeGPT": [
503
  # Load pages from functions
 
311
 
312
 
313
  def dynamic_forecasting():
314
+ st.title("Personalized Neural Forecasting")
315
  st.markdown("""
316
  Train time series forecasting model from scratch and provide forecasts/visualization by using various deep neural network-based model trained on user data.
317
 
 
414
 
415
  df = df.drop_duplicates(subset=['ds']).reset_index(drop=True)
416
 
417
+
418
  if st.sidebar.button("Submit"):
419
+ start_time = time.time()
420
  forecast_df = nixtla_client.forecast(
421
  df=df,
422
  h=h,
 
425
  )
426
  st.session_state.forecast_df = forecast_df
427
 
428
+
429
+ if 'forecast_df' in st.session_state:
430
+ forecast_df = st.session_state.forecast_df
431
+ st.pyplot(nixtla_client.plot(df, forecast_df, level=[90]))
432
+
433
+ end_time = time.time() # End timing
434
+ time_taken = end_time - start_time
435
+ st.success(f"Time taken for {model_choice} forecast: {time_taken:.2f} seconds")
436
 
437
 
438
 
 
484
 
485
  df = df.drop_duplicates(subset=['ds']).reset_index(drop=True)
486
  if st.sidebar.button("Submit"):
487
+ start_time=time.time()
488
  anom_df = nixtla_client.detect_anomalies(
489
  df=df,
490
  freq=freq,
 
492
  )
493
  st.session_state.anom_df = anom_df
494
 
495
+ if 'anom_df' in st.session_state:
496
+ anom_df = st.session_state.anom_df
497
+ st.pyplot(nixtla_client.plot(df, anom_df))
498
+
499
+ end_time = time.time() # End timing
500
+ time_taken = end_time - start_time
501
+ st.success(f"Time taken for {model_choice} forecast: {time_taken:.2f} seconds")
502
 
503
 
504
 
 
508
  "Neuralforecast": [
509
  # Load pages from functions
510
  st.Page(transfer_learning_forecasting, title="Zero-shot Forecasting", default=True, icon=":material/query_stats:"),
511
+ st.Page(dynamic_forecasting, title="Personalized Neural Forecasting", icon=":material/monitoring:"),
512
  ],
513
  "TimeGPT": [
514
  # Load pages from functions