fmegahed commited on
Commit
7b16b97
·
verified ·
1 Parent(s): dcff188

Updated the presentation of the evaluation results and updated the default models

Browse files
Files changed (1) hide show
  1. app.py +30 -9
app.py CHANGED
@@ -295,9 +295,29 @@ def run_forecast(
295
  finetune_loss=finetune_loss
296
  )
297
 
298
- # Combine results
 
299
  if not combined_eval_df.empty and not timegpt_eval_df.empty:
300
- combined_eval_df = pd.concat([combined_eval_df, timegpt_eval_df], ignore_index=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  else:
302
  combined_eval_df = timegpt_eval_df if not timegpt_eval_df.empty else combined_eval_df
303
 
@@ -956,7 +976,8 @@ with gr.Blocks(title="Time Series Forecasting App", theme=theme) as app:
956
  with gr.Accordion("Data & Validation Settings", open=True):
957
  frequency = gr.Dropdown(
958
  choices=[
959
- ("Hourly", "H"),
 
960
  ("Daily", "D"),
961
  ("Weekly", "WS"),
962
  ("Monthly", "MS"),
@@ -964,7 +985,7 @@ with gr.Blocks(title="Time Series Forecasting App", theme=theme) as app:
964
  ("Yearly", "YS")
965
  ],
966
  label="Data Frequency",
967
- value="D"
968
  )
969
 
970
  # Evaluation Strategy
@@ -1012,17 +1033,17 @@ with gr.Blocks(title="Time Series Forecasting App", theme=theme) as app:
1012
 
1013
  gr.Markdown("### Window-based Models")
1014
  with gr.Row():
1015
- use_window_avg = gr.Checkbox(label="Window Average", value=True)
1016
  window_size = gr.Number(label="Window Size", value=10)
1017
 
1018
  with gr.Row():
1019
- use_seasonal_window_avg = gr.Checkbox(label="Seasonal Window Average", value=True)
1020
  seasonal_window_size = gr.Number(label="Seasonal Window Size", value=2)
1021
 
1022
  gr.Markdown("### Advanced Models (use seasonality from above)")
1023
  with gr.Row():
1024
- use_autoets = gr.Checkbox(label="AutoETS (Exponential Smoothing)", value=True)
1025
- use_autoarima = gr.Checkbox(label="AutoARIMA", value=True)
1026
 
1027
  # Transformer Models Tab (TimeGPT)
1028
  with gr.TabItem("Transformer Models"):
@@ -1030,7 +1051,7 @@ with gr.Blocks(title="Time Series Forecasting App", theme=theme) as app:
1030
  gr.Markdown("TimeGPT uses a transformer architecture for state-of-the-art time series forecasting")
1031
 
1032
  with gr.Row():
1033
- use_timegpt = gr.Checkbox(label="Use TimeGPT", value=False)
1034
 
1035
  with gr.Group():
1036
  gr.Markdown("### TimeGPT Configuration")
 
295
  finetune_loss=finetune_loss
296
  )
297
 
298
+
299
+ # Combine results - using merge instead of concat to avoid duplicate rows
300
  if not combined_eval_df.empty and not timegpt_eval_df.empty:
301
+ # Get common columns for the join
302
+ join_columns = ['unique_id', 'metric']
303
+ # Merge the dataframes on unique_id and metric
304
+ combined_eval_df = pd.merge(
305
+ combined_eval_df,
306
+ timegpt_eval_df,
307
+ on=join_columns,
308
+ how='outer',
309
+ suffixes=('', '_timegpt')
310
+ )
311
+
312
+ # Clean up any duplicated columns from the merge
313
+ for col in combined_eval_df.columns:
314
+ if col.endswith('_timegpt'):
315
+ base_col = col.replace('_timegpt', '')
316
+ # Fill NaN values in the original column with values from the _timegpt column
317
+ if base_col in combined_eval_df.columns:
318
+ combined_eval_df[base_col] = combined_eval_df[base_col].fillna(combined_eval_df[col])
319
+ # Remove the _timegpt column
320
+ combined_eval_df = combined_eval_df.drop(columns=[col])
321
  else:
322
  combined_eval_df = timegpt_eval_df if not timegpt_eval_df.empty else combined_eval_df
323
 
 
976
  with gr.Accordion("Data & Validation Settings", open=True):
977
  frequency = gr.Dropdown(
978
  choices=[
979
+ ("Hourly", "H"),
980
+ ("Business Day", "B"),
981
  ("Daily", "D"),
982
  ("Weekly", "WS"),
983
  ("Monthly", "MS"),
 
985
  ("Yearly", "YS")
986
  ],
987
  label="Data Frequency",
988
+ value="B"
989
  )
990
 
991
  # Evaluation Strategy
 
1033
 
1034
  gr.Markdown("### Window-based Models")
1035
  with gr.Row():
1036
+ use_window_avg = gr.Checkbox(label="Window Average", value=False)
1037
  window_size = gr.Number(label="Window Size", value=10)
1038
 
1039
  with gr.Row():
1040
+ use_seasonal_window_avg = gr.Checkbox(label="Seasonal Window Average", value=False)
1041
  seasonal_window_size = gr.Number(label="Seasonal Window Size", value=2)
1042
 
1043
  gr.Markdown("### Advanced Models (use seasonality from above)")
1044
  with gr.Row():
1045
+ use_autoets = gr.Checkbox(label="AutoETS (Exponential Smoothing)", value=False)
1046
+ use_autoarima = gr.Checkbox(label="AutoARIMA", value=False)
1047
 
1048
  # Transformer Models Tab (TimeGPT)
1049
  with gr.TabItem("Transformer Models"):
 
1051
  gr.Markdown("TimeGPT uses a transformer architecture for state-of-the-art time series forecasting")
1052
 
1053
  with gr.Row():
1054
+ use_timegpt = gr.Checkbox(label="Use TimeGPT", value=True)
1055
 
1056
  with gr.Group():
1057
  gr.Markdown("### TimeGPT Configuration")