Time-Series involves temporal datasets that change over a period of time and time-based attributes are of paramount importance in these datasets. The trading prices of stocks change constantly over time, and reflect various unmeasured factors such as market confidence, external influences, and other driving forces that may be hard to identify or measure. There are hypothesis like the Efficient Market Hypothesis, which says that it is almost impossible to beat the market consistently and there are others which disagree with it.

Problem Statement

Forecasting the future value of a given stock is a crucial task as investing in stock market involves higher risk… Here, given the historical daily close price for Dow-Jones Index, we would like to prepare and compare forecasting models.

dji = web.DataReader('^DJI', data_source = 'yahoo', start = '2000-01-01')
print(dji.head())
print('\n')
print(dji.shape)

dji_series = dji[‘Adj Close’]

#Calculate the simple and log returns using the adj close prices:
dji[‘simple_rtn’] = dji_series.pct_change()
dji[‘log_rtn’] = np.log(dji_series/dji_series.shift(1))
fig, ax = plt.subplots(3, 1, figsize=(14, 10), sharex=True)
dji_series.plot(ax=ax[0])
ax[0].set(title = ‘DJIJ time series’, ylabel = ‘Dow Jones Adj Close price ($)’)
dji.simple_rtn.plot(ax=ax[1])
ax[1].set(ylabel = ‘Simple returns (%)’)
dji.log_rtn.plot(ax=ax[2])
ax[2].set(xlabel = ‘Date’, ylabel = ‘Log returns (%)’)
plt.show()


![](https://miro.medium.com/max/60/1*maA-paxhdqzIRNJAOUcVDg.png?q=20)

#predictive-modeling #analytics #machine-learning

Time Series Analysis & Predictive Modeling Using Machine Learning
1.40 GEEK