Time series analysis with Corona Virus Daily Data and ARIMA models
In statistics and econometrics, and in particular in time series analysis, an autoregressive integrated moving average (ARIMA) model is a generalization of an autoregressive moving average (ARMA) model. Both of these models are fitted to time series data either to better understand the data or to predict future points in the series (forecasting). WIKIPEDIA
-
Use
getData.py
to bring./data/data.csv
Corona virus daily status Dataset -
Show a Data Graph
data = getData.read_csv('list')
def ShowGraph(data):
df = pd.DataFrame(data, columns = ['date' , 'value'])
df.date = pd.to_datetime(df.date)
df.value = pd.to_numeric(df['value'])
df = df.set_index('date')
g = df['value'].plot(title="Corona-Virus Daily data")
plt = g.get_figure()
...
- ACF & PAF Calculation and Show a graphs
def Calc_ACF_PAF():
...
plot_acf(data)
plot_pacf(data)
...
Left : ACF / Right : PACF
- Forecast using ARIMA models
def ARIMA():
...
order = (0,1,1)
model = statsmodels.tsa.arima_model.ARIMA(series, order, freq='D')
model_fit = model.fit(trend='c',full_output=True, disp=10)
...
- Show a graph
def ARIMA():
...
plt = model_fit.plot_predict()
Number_to_predict = 3
fore = model_fit.forecast(steps=Number_to_predict)
...
Orange Line : Origin / Blue Line : Forecast
- Result
for x in fore[0]:
p_time = time + timedelta(days=Number_to_predict)
p_time = p_time.strftime('%Y-%m-%d')
print("{0} : {1}".format(p_time, x))
Number_to_predict += 1
# Output
2020-03-09 : 6057.29830482379
2020-03-10 : 6196.215619909736
2020-03-11 : 6335.132934995682
날짜 | Predict | Actuality | Difference |
---|---|---|---|
2020-03-09 | 6057 | 7382 | 1325 |
2020-03-10 | 6196 | 7513 | 1317 |
2020-03-11 | 6335 | 7755 | 1420 |
- Window 10
- Python 3.6