Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -209,7 +209,7 @@ def transfer_learning_forecasting():
|
|
209 |
with st.sidebar.expander("Upload and Configure Dataset", expanded=True):
|
210 |
uploaded_file = st.file_uploader("Upload your time series data (CSV)", type=["csv"])
|
211 |
if uploaded_file:
|
212 |
-
df = pd.read_csv(uploaded_file)
|
213 |
st.session_state.df = df
|
214 |
else:
|
215 |
df = load_default()
|
@@ -377,53 +377,13 @@ def timegpt_fcst():
|
|
377 |
)
|
378 |
st.write(forecast_df)
|
379 |
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
# def timegpt_fcst():
|
387 |
-
# nixtla_token = os.environ.get("NIXTLA_API_KEY")
|
388 |
-
# nixtla_client = NixtlaClient(api_key=nixtla_token)
|
389 |
-
|
390 |
-
# st.title("TimeGPT Forecasting")
|
391 |
-
# with st.sidebar.expander("Upload and Configure Dataset", expanded=True):
|
392 |
-
# uploaded_file = st.file_uploader("Upload your time series data (CSV)", type=["csv"])
|
393 |
-
# if uploaded_file:
|
394 |
-
# df = pd.read_csv(uploaded_file)
|
395 |
-
# st.session_state.df = df
|
396 |
-
# else:
|
397 |
-
# df = load_default()
|
398 |
-
# st.session_state.df = df
|
399 |
-
|
400 |
-
# columns = df.columns.tolist()
|
401 |
-
# st.write("Columns in the uploaded dataset:", columns) # Debug statement
|
402 |
-
|
403 |
-
# ds_col = st.selectbox("Select Date/Time column", options=columns, index=columns.index('ds') if 'ds' in columns else 0)
|
404 |
-
# y_col = st.selectbox("Select Target column", options=[col for col in columns if col != ds_col], index=0)
|
405 |
-
|
406 |
-
# df = df.rename(columns={ds_col: 'ds', y_col: 'y'})
|
407 |
-
# st.write("Renamed DataFrame columns:", df.columns) # Debug statement
|
408 |
-
|
409 |
-
# id_col = 'ts_test'
|
410 |
-
# df['unique_id'] = id_col
|
411 |
-
# freq = determine_frequency(df)
|
412 |
-
|
413 |
-
# st.write("DataFrame after renaming and adding 'unique_id':", df.head()) # Debug statement
|
414 |
-
|
415 |
-
# forecast_df = nixtla_client.forecast(
|
416 |
-
# df=df,
|
417 |
-
# h=7,
|
418 |
-
# freq=freq,
|
419 |
-
# level=[90]
|
420 |
-
# )
|
421 |
|
422 |
-
# nixtla_client.plot(
|
423 |
-
# forecast_df,
|
424 |
-
# level=[90],
|
425 |
-
# max_insample_length=365
|
426 |
-
# )
|
427 |
|
428 |
|
429 |
def timegpt_anom():
|
@@ -462,6 +422,8 @@ def timegpt_anom():
|
|
462 |
st.session_state.ds_col = ds_col
|
463 |
st.session_state.y_col = y_col
|
464 |
|
|
|
|
|
465 |
if st.sidebar.button("Submit"):
|
466 |
anom_df = nixtla_client.detect_anomalies(
|
467 |
df=df,
|
|
|
209 |
with st.sidebar.expander("Upload and Configure Dataset", expanded=True):
|
210 |
uploaded_file = st.file_uploader("Upload your time series data (CSV)", type=["csv"])
|
211 |
if uploaded_file:
|
212 |
+
df = pd.read_csv(uploaded_file, index_col=0)
|
213 |
st.session_state.df = df
|
214 |
else:
|
215 |
df = load_default()
|
|
|
377 |
)
|
378 |
st.write(forecast_df)
|
379 |
|
380 |
+
nixtla_client.plot(
|
381 |
+
df,
|
382 |
+
forecast_df,
|
383 |
+
level=[90],
|
384 |
+
max_insample_length=365
|
385 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
|
|
|
|
|
|
|
|
|
|
|
387 |
|
388 |
|
389 |
def timegpt_anom():
|
|
|
422 |
st.session_state.ds_col = ds_col
|
423 |
st.session_state.y_col = y_col
|
424 |
|
425 |
+
freq = determine_frequency(df)
|
426 |
+
|
427 |
if st.sidebar.button("Submit"):
|
428 |
anom_df = nixtla_client.detect_anomalies(
|
429 |
df=df,
|