Spaces:
Running
Running
Ignored the confidence level for simplicty
Browse files
app.py
CHANGED
|
@@ -52,6 +52,7 @@ def create_forecast_plot(forecast_df, original_df, title="Forecasting Results"):
|
|
| 52 |
forecast_cols = [col for col in forecast_df.columns if col not in ['unique_id', 'ds', 'cutoff']]
|
| 53 |
|
| 54 |
colors = plt.cm.tab10.colors
|
|
|
|
| 55 |
|
| 56 |
for i, unique_id in enumerate(unique_ids):
|
| 57 |
original_data = original_df[original_df['unique_id'] == unique_id]
|
|
@@ -257,16 +258,14 @@ def run_forecast(
|
|
| 257 |
timegpt_cv_df = nixtla_client.cross_validation(
|
| 258 |
df=df,
|
| 259 |
h=horizon,
|
| 260 |
-
freq=frequency,
|
| 261 |
-
level=level,
|
| 262 |
n_windows=num_windows,
|
| 263 |
step_size=step_size
|
| 264 |
)
|
| 265 |
timegpt_cv_eval = evaluate(
|
| 266 |
df=timegpt_cv_df,
|
| 267 |
metrics=[mape, mae, rmse, bias],
|
| 268 |
-
models=['TimeGPT'],
|
| 269 |
-
level=level
|
| 270 |
)
|
| 271 |
timegpt_eval_df = pd.DataFrame(timegpt_cv_eval).reset_index()
|
| 272 |
else: # Fixed window
|
|
@@ -274,15 +273,13 @@ def run_forecast(
|
|
| 274 |
df=df,
|
| 275 |
h=horizon,
|
| 276 |
freq=frequency,
|
| 277 |
-
level=level,
|
| 278 |
n_windows=1,
|
| 279 |
step_size=10
|
| 280 |
)
|
| 281 |
timegpt_cv_eval = evaluate(
|
| 282 |
df=timegpt_cv_df,
|
| 283 |
metrics=[mape, mae, rmse, bias],
|
| 284 |
-
models=['TimeGPT']
|
| 285 |
-
level=level
|
| 286 |
)
|
| 287 |
timegpt_eval_df = pd.DataFrame(timegpt_cv_eval).reset_index()
|
| 288 |
|
|
@@ -290,8 +287,7 @@ def run_forecast(
|
|
| 290 |
forecast_timegpt = nixtla_client.forecast(
|
| 291 |
df=df,
|
| 292 |
h=future_horizon,
|
| 293 |
-
freq=frequency,
|
| 294 |
-
level=level,
|
| 295 |
finetune_loss=finetune_loss
|
| 296 |
)
|
| 297 |
|
|
@@ -985,7 +981,7 @@ with gr.Blocks(title="Time Series Forecasting App", theme=theme) as app:
|
|
| 985 |
("Yearly", "YS")
|
| 986 |
],
|
| 987 |
label="Data Frequency",
|
| 988 |
-
value="
|
| 989 |
)
|
| 990 |
|
| 991 |
# Evaluation Strategy
|
|
|
|
| 52 |
forecast_cols = [col for col in forecast_df.columns if col not in ['unique_id', 'ds', 'cutoff']]
|
| 53 |
|
| 54 |
colors = plt.cm.tab10.colors
|
| 55 |
+
min_cutoff = None
|
| 56 |
|
| 57 |
for i, unique_id in enumerate(unique_ids):
|
| 58 |
original_data = original_df[original_df['unique_id'] == unique_id]
|
|
|
|
| 258 |
timegpt_cv_df = nixtla_client.cross_validation(
|
| 259 |
df=df,
|
| 260 |
h=horizon,
|
| 261 |
+
freq=frequency,
|
|
|
|
| 262 |
n_windows=num_windows,
|
| 263 |
step_size=step_size
|
| 264 |
)
|
| 265 |
timegpt_cv_eval = evaluate(
|
| 266 |
df=timegpt_cv_df,
|
| 267 |
metrics=[mape, mae, rmse, bias],
|
| 268 |
+
models=['TimeGPT'],
|
|
|
|
| 269 |
)
|
| 270 |
timegpt_eval_df = pd.DataFrame(timegpt_cv_eval).reset_index()
|
| 271 |
else: # Fixed window
|
|
|
|
| 273 |
df=df,
|
| 274 |
h=horizon,
|
| 275 |
freq=frequency,
|
|
|
|
| 276 |
n_windows=1,
|
| 277 |
step_size=10
|
| 278 |
)
|
| 279 |
timegpt_cv_eval = evaluate(
|
| 280 |
df=timegpt_cv_df,
|
| 281 |
metrics=[mape, mae, rmse, bias],
|
| 282 |
+
models=['TimeGPT']
|
|
|
|
| 283 |
)
|
| 284 |
timegpt_eval_df = pd.DataFrame(timegpt_cv_eval).reset_index()
|
| 285 |
|
|
|
|
| 287 |
forecast_timegpt = nixtla_client.forecast(
|
| 288 |
df=df,
|
| 289 |
h=future_horizon,
|
| 290 |
+
freq=frequency,
|
|
|
|
| 291 |
finetune_loss=finetune_loss
|
| 292 |
)
|
| 293 |
|
|
|
|
| 981 |
("Yearly", "YS")
|
| 982 |
],
|
| 983 |
label="Data Frequency",
|
| 984 |
+
value="D"
|
| 985 |
)
|
| 986 |
|
| 987 |
# Evaluation Strategy
|