I am making a Streamlit application to do experimentation on data using pycaret time series. I created a function to return the experiment and return the information I need, but for some reason I am getting only one of the 2 plots I am returning (out-of-sample). The insample
doesn't show!
Here is my code:
from pycaret.time_series import TSForecastingExperiment
import streamlit as st
exp_auto = TSForecastingExperiment()
def run_pycaret(df, target='qty', horizon=12):
exp_auto.setup(
data=df, target=target, fh=horizon, enforce_exogenous=False,
numeric_imputation_target="ffill", numeric_imputation_exogenous="ffill",
scale_target="minmax",
scale_exogenous="minmax",
fold_strategy="expanding",
session_id=42, verbose=False)
best = exp_auto.compare_models(sort="mape", turbo=False, verbose=False)
metrics = exp_auto.pull()
insample = exp_auto.plot_model(best, plot='insample',display_format='streamlit')
outsample = exp_auto.plot_model(best, plot='forecast', display_format='streamlit')
return best, metrics, insample, outsample
if st.button("Run Time series models:"):
best, metrics, insample, outsample = run_pycaret(df_exog, horizon=steps)
st.write(metrics)
# Plot graph
col1_ts_exp, col2_ts_exp = st.columns(2)
with col1_ts_exp:
insample
with col2_ts_exp:
outsample