( ) - ( ) ( ('Lower New - Vaccinations - Smoothed') ) ( ('Upper New - Vaccinations - Smoothed') ) - (., ,, 'B', )
( ) - ( ) ( ('Lower New - Vaccinations - Smoothed') ) ( ('Upper New - Vaccinations - Smoothed') ) - (., ,, 'B', )
import os
import sys
from tempfile import NamedTemporaryFile
from urllib.request import urlopen
from urllib.parse import unquote, urlparse
from urllib.error import HTTPError
from zipfile import ZipFile
import tarfile
import shutil
CHUNK_SIZE = 40960
DATA_SOURCE_MAPPING = 'latest-covid-19-dataset-worldwide:https%3A%2F%2Fsiteproxy.ruqli.workers.dev%3A443%2Fhttps%2Fstorage.googleapis.com%2Fkaggle-data-sets%2F1852043%2F3023973%2Fbundle%2Farc
KAGGLE_INPUT_PATH='/kaggle/input'
KAGGLE_WORKING_PATH='/kaggle/working'
KAGGLE_SYMLINK='kaggle'
try:
os.symlink(KAGGLE_INPUT_PATH, os.path.join("..", 'input'), target_is_directory=True)
except FileExistsError:
pass
try:
os.symlink(KAGGLE_WORKING_PATH, os.path.join("..", 'working'), target_is_directory=True)
except FileExistsError:
pass
# Plotting
import seaborn as sns
import matplotlib.pyplot as plt
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
In [ ]: df = pd.read_csv('../input/latest-covid-19-dataset-worldwide/owid-covid-data (2).csv')
In [ ]: df['date'] = pd.to_datetime(df['date'])
df = df[df['iso_code']=='NGA']
df = df.set_index('date')
hospitalized = df[['new_vaccinations_smoothed']]
hospitalized = hospitalized.resample('W-MON').mean()
In [ ]: hospitalized.plot()
In [ ]: hospitalized = hospitalized.dropna()
In [ ]: hospitalized.plot()
In [ ]: result = adfuller(hospitalized)
print('ADF Statistic: %f' % result[0])
print('p-value: %f' % result[1])
In [ ]: diffhosp.plot()
pacf = plot_pacf(diffhosp)
acf = plot_acf(diffhosp)
- 01-10-2022
Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-step).
[2] Covariance matrix is singular or near-singular, with condition number 4.63e+32. Standard errors may be unstable.
In [ ]: predictions = model.predict()
plt.figure(figsize=(15,10))
plt.plot(predictions[1:])
plt.plot(hospitalized)
In [ ]: train = hospitalized[:-5]
test = hospitalized[-5:]
model = ARIMA(train,order= (2,1,2)).fit()
model.summary()
- 12-06-2021
Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-step).
[2] Covariance matrix is singular or near-singular, with condition number 2.09e+33. Standard errors may be unstable.
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-29-c01453b67fd5> in <cell line: 7>()
5 plt.plot((test))
6 conf= predictions.conf_int(alpha=0.05)
----> 7 upper = (conf['lower new_vaccinations_smoothed'])
8 lower = (conf['upper new_vaccinations_smoothed'])
9 plt.fill_between(upper.index, upper,lower, color='b', alpha=.1)
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
In [ ]: plt.figure(figsize=(15,6))
plt.plot((train))
plt.plot((test_res))
corr = df.corr()
hospcorr = corr['new_vaccinations_smoothed']
hospcorr = hospcorr[np.abs(hospcorr)>0.4]
hospcorr.sort_values()
In [ ]: exogfeats = df[['stringency_index','total_deaths_per_million','total_cases_per_million']]
In [ ]: exogfeats = exogfeats.resample('W-MON').mean()
exogfeats = exogfeats.iloc[(exogfeats.index >= hospitalized.first_valid_index()) & (exogfeats.index<= hospitalized.last_valid_index())]
- 01-10-2022
Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-step).
[2] Covariance matrix is singular or near-singular, with condition number 5.09e+26. Standard errors may be unstable.
In [ ]: plt.figure(figsize=(15,6))
plt.legend(["a","b"])
plt.plot(hospitalized)
plt.plot(predictions[1:])
plt.show()
In [ ]: test_length = 5
train = hospitalized[:-test_length]
test = hospitalized[-test_length:]
train_exog = exogfeats[:-test_length]
test_exog = exogfeats[-test_length:]
model = ARIMA(train,order= (2,1,2),exog=train_exog).fit()
In [ ]: