I want to implement prophet algorithm and use my dataset on the model. After fit process i got following error in predict process. How can i solve this problem.?
import pandas as pd
import pystan
from prophet import Prophet
df_prophet = df[['date', 'rate']]
train_df = df_prophet[:-5]
train_df.columns = ['ds', 'y']
train_df['ds']= to_datetime(train_df['ds'])
model = Prophet()
model.fit(train_df)
test_df = df_prophet[-5:][['date']]
test_list = to_datetime(test_df.date).values
forecast = model.predict(test_list)
---> 11 forecast = model.predict(test_list)
IndexError: only integers, slices (
:
), ellipsis (...
), numpy.newaxis (None
) and integer or boolean arrays are valid indices
It's a nice attempt. You just need a few tweaks.
to_datetime(test_df.date).values
you were creating a numpy array instead of a dataframe.Prophet
expects a dataframe.Prophet
model and predictor expects columns labeledds
andy
and you're changing the column names after you split the dataframe, so your test part isn't getting the columns renamed.pystan
since the Prophet module is built on it already.Try this: