Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -69,14 +69,20 @@ def determine_frequency(df):
|
|
| 69 |
df = df.drop_duplicates(subset='ds')
|
| 70 |
df = df.set_index('ds')
|
| 71 |
|
| 72 |
-
# Create a complete date range
|
| 73 |
-
full_range = pd.date_range(start=df.index.min(), end=df.index.max())
|
| 74 |
|
| 75 |
-
# Reindex the DataFrame to this full date range
|
| 76 |
-
df_full = df.reindex(full_range)
|
| 77 |
|
| 78 |
# Infer the frequency
|
| 79 |
-
freq = pd.infer_freq(df_full.index)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
return freq
|
| 81 |
|
| 82 |
def plot_forecasts(forecast_df, train_df, title):
|
|
@@ -375,14 +381,13 @@ def timegpt_fcst():
|
|
| 375 |
freq=freq,
|
| 376 |
level=[90]
|
| 377 |
)
|
| 378 |
-
st.write(forecast_df)
|
| 379 |
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
|
| 387 |
|
| 388 |
|
|
@@ -431,10 +436,10 @@ def timegpt_anom():
|
|
| 431 |
level=90
|
| 432 |
)
|
| 433 |
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
|
| 439 |
|
| 440 |
|
|
|
|
| 69 |
df = df.drop_duplicates(subset='ds')
|
| 70 |
df = df.set_index('ds')
|
| 71 |
|
| 72 |
+
# # Create a complete date range
|
| 73 |
+
# full_range = pd.date_range(start=df.index.min(), end=df.index.max(),freq=freq)
|
| 74 |
|
| 75 |
+
# # Reindex the DataFrame to this full date range
|
| 76 |
+
# df_full = df.reindex(full_range)
|
| 77 |
|
| 78 |
# Infer the frequency
|
| 79 |
+
# freq = pd.infer_freq(df_full.index)
|
| 80 |
+
|
| 81 |
+
freq = pd.infer_freq(df.index)
|
| 82 |
+
if not freq:
|
| 83 |
+
st.warning('The forecast will use default Daily forecast due to date inconsistency. Please check your data.',icon="⚠️")
|
| 84 |
+
freq = 'D'
|
| 85 |
+
|
| 86 |
return freq
|
| 87 |
|
| 88 |
def plot_forecasts(forecast_df, train_df, title):
|
|
|
|
| 381 |
freq=freq,
|
| 382 |
level=[90]
|
| 383 |
)
|
|
|
|
| 384 |
|
| 385 |
+
st.pyplot(nixtla_client.plot(
|
| 386 |
+
df,
|
| 387 |
+
forecast_df,
|
| 388 |
+
level=[90],
|
| 389 |
+
max_insample_length=365
|
| 390 |
+
))
|
| 391 |
|
| 392 |
|
| 393 |
|
|
|
|
| 436 |
level=90
|
| 437 |
)
|
| 438 |
|
| 439 |
+
st.pyplot(nixtla_client.plot(
|
| 440 |
+
df,
|
| 441 |
+
anom_df
|
| 442 |
+
))
|
| 443 |
|
| 444 |
|
| 445 |
|