#!/usr/bin/env python
# coding: utf-8

# In[11]:


import pandas
from pandas import read_csv
from pandas import datetime
from matplotlib import pyplot
from statsmodels.tsa.arima.model import ARIMA
from sklearn.metrics import mean_squared_error
from math import sqrt
import os
# load dataset
os.chdir("C:\\Users\\SOS\\PycharmProjects\\pythonProject2\\data")
ts = open('sampledata.csv')
tsA = ts.read().split('\n')
tsA = list(map(int, tsA))


# split into train and test sets

size = int(len(tsA) * 0.66)
train, test = tsA[0:size], tsA[size:len(tsA)]
history = [x for x in train]
predictions = list()
# walk-forward validation
for t in range(len(test)):
	model = ARIMA(history, order=(5, 1, 0))
	model_fit = model.fit()
	output = model_fit.forecast()
	yhat = output[0]
	predictions.append(yhat)
	obs = test[t]
	history.append(obs)
	print('predicted=%f, expected=%f' % (yhat, obs))
# evaluate forecasts
rmse = sqrt(mean_squared_error(test, predictions))
print('Test RMSE: %.3f' % rmse)
# plot forecasts against actual outcomes
pyplot.plot(test)
pyplot.plot(predictions, color='red')
pyplot.show()


# In[ ]:




