alladinsane
alladinsane

Reputation: 185

Training ARIMA to forecast the trend

I'm trying to forecast a trend using ARIMA. Unfortunately the output I get is far different from the expected one (behaviour for training and testing data is very similiar) and indicates as if the whole training data set was... useless?

df = pd.read_csv('data.csv')
df.index = pd.DatetimeIndex(df.index).to_period('D')

#data from 1/1/2016 to 31/12/2018
train = df.loc[:'2018-12-31']
test = df.loc['2019-01-01':]

model = auto_arima(train, start_p=1, start_q=1,
                   max_p=3, max_q=3, m=7,
                   start_P=0, seasonal=True,
                   d=1, D=1, trace=True,
                   error_action='ignore',
                   suppress_warnings=True,
                   stepwise=True)

model.aic()
model.fit(train)
ffforecast = model.predict(n_periods=len(test))
ffforecast = pd.DataFrame(fforecast,
                               index=test.index,
                               columns=['prediction'])
pd.concat([test, fforecast], axis=1).plot()
pyplot.show()

enter image description here

full code: https://pastebin.com/huer62cM

csv: https://filebin.net/rlvm3hrjetlovd64/newbikes6years.csv?t=nt3slw3y

Upvotes: 0

Views: 136

Answers (1)

Chris
Chris

Reputation: 16172

You're using a bad set of parameters for your model. It looks like you copy/pasted an example from a different data set and it's not working for you.

I would suggest something like:

model = auto_arima(train, error_action='ignore', trace=True, suppress_warnings=True,seasonal=True, maxiter=10, m=7)

Based on the output of this, you can go back and refine the parameters once you read up on them and learn what they do.

Upvotes: 1

Related Questions