Hi
I am trying to pull column names using st.multiselect widget in model.add_regressor prophet for time series forecasting. I am able to pull only 1 column and need to knoe how to pull selected column?
Thanks
Hi there,
Thanks for sharing your question with the community! Check out our guidelines on how to post an effective question here â in particular, please share a code snippet so we can reproduce the issue.
Thanks
Here is the piece of my codeâŠ
Add regressors
columns=st.multiselect("Select regressor variables columns",df.columns.unique())
model_new = Prophet() #instantiate Prophet
for k in columns:
model_new.add_regressor(k)
model_new.fit(df)
future_data = model_new.make_future_dataframe(periods= dur,freq = freq)
df=df.append(df_test)
st.info("This is future_data for forecast")
future_data=df[['ds',k]]
st.write(future_data)
# Forecast Button
if st.button(âForecastâ):
st.spinner()
with st.spinner(text=âProphet is forecastingâŠâ):
forecast_data = model_new.predict(future_data)
st.write(forecast_data[[âdsâ, âyhatâ, âyhat_lowerâ, âyhat_upperâ]].tail(5))
Here is the output in streamlit
I want to ask, when I select 3 regressors, the future dataframe takes only one as a result, it raises value error while predicting?
How to get rid of this, could you please help?
Thanks a lot.
You have k
here when it looks like it was instantiated for iteration in the loop above. You need to make a list that includes âdsâ and all the entries in columns
from the multiselect.
result_cols = ['ds'] + columns
future_data=df[result_cols]
Thanks a lot!
This really works for me.
Now future dataframe is taking all parameters for forecast.
Thanks once again.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.