Cainvas

COVID-19 Data Analysis and prediction using Facebook's prophet model

Necessary libraries

In [ ]:
pip install pandas
In [ ]:
pip install matplotlib
In [ ]:
pip install seaborn
In [ ]:
pip install fbprophet
In [4]:
import pandas as pd
from matplotlib import pyplot as plt 
import seaborn as sns
import datetime as dt
import numpy as np

DataSet

    The dataset used in this covid19 prediction and analysis project in India are obtained from kaggle,

  1. covid_19_india.csv that contains the data of date, Time, State/ Union territory, Confirmed cases,deaths and cured cases.
  2. StatewiseTestingDetails.csv contains the test data of all the states and Unionterritory.
In [5]:
#importing main dataset 
df = pd.read_csv('https://cainvas-static.s3.amazonaws.com/media/user_data/AnandKumarE0/covid_19_india.csv', parse_dates=['Date'], dayfirst=True)
In [6]:
df.head()
Out[6]:
Sno Date Time State/UnionTerritory ConfirmedIndianNational ConfirmedForeignNational Cured Deaths Confirmed
0 1 2020-01-30 6:00 PM Kerala 1 0 0 0 1
1 2 2020-01-31 6:00 PM Kerala 1 0 0 0 1
2 3 2020-02-01 6:00 PM Kerala 2 0 0 0 2
3 4 2020-02-02 6:00 PM Kerala 3 0 0 0 3
4 5 2020-02-03 6:00 PM Kerala 3 0 0 0 3
In [7]:
df.tail()
Out[7]:
Sno Date Time State/UnionTerritory ConfirmedIndianNational ConfirmedForeignNational Cured Deaths Confirmed
5646 5647 2020-08-27 8:00 AM Telengana - - 86095 788 114483
5647 5648 2020-08-27 8:00 AM Tripura - - 6697 85 9908
5648 5649 2020-08-27 8:00 AM Uttarakhand - - 11524 219 16549
5649 5650 2020-08-27 8:00 AM Uttar Pradesh - - 148562 3149 203028
5650 5651 2020-08-27 8:00 AM West Bengal - - 117857 2964 147775

Changing the column names

In [8]:
#keeping only required columns
df= df[['Date','State/UnionTerritory','Cured','Deaths','Confirmed']]

df.columns=['date', 'state','cured','deaths','confirmed' ]
In [9]:
#Looking at the earlier dates
df.head()
Out[9]:
date state cured deaths confirmed
0 2020-01-30 Kerala 0 0 1
1 2020-01-31 Kerala 0 0 1
2 2020-02-01 Kerala 0 0 2
3 2020-02-02 Kerala 0 0 3
4 2020-02-03 Kerala 0 0 3

Today's covid data

In [10]:
#current date
today = df[df.date == '2020-08-27']
In [11]:
today.shape
Out[11]:
(35, 5)
In [12]:
today
Out[12]:
date state cured deaths confirmed
5616 2020-08-27 Andaman and Nicobar Islands 2309 41 2985
5617 2020-08-27 Andhra Pradesh 286720 3541 382469
5618 2020-08-27 Arunachal Pradesh 2563 5 3555
5619 2020-08-27 Assam 76962 274 96771
5620 2020-08-27 Bihar 106361 530 126714
5621 2020-08-27 Chandigarh 1796 41 3376
5622 2020-08-27 Chhattisgarh 14145 231 24550
5623 2020-08-27 Dadra and Nagar Haveli and Daman and Diu 1862 2 2228
5624 2020-08-27 Delhi 148897 4347 165764
5625 2020-08-27 Goa 11511 165 15027
5626 2020-08-27 Gujarat 72282 2945 89994
5627 2020-08-27 Haryana 47613 634 58005
5628 2020-08-27 Himachal Pradesh 3810 32 5321
5629 2020-08-27 Jammu and Kashmir 26193 657 34480
5630 2020-08-27 Jharkhand 22349 362 33046
5631 2020-08-27 Karnataka 211688 5091 300406
5632 2020-08-27 Kerala 41690 257 64355
5633 2020-08-27 Ladakh 1580 25 2451
5634 2020-08-27 Madhya Pradesh 43246 1282 56864
5635 2020-08-27 Maharashtra 522427 23089 718711
5636 2020-08-27 Manipur 3829 25 5585
5637 2020-08-27 Meghalaya 874 8 2050
5638 2020-08-27 Mizoram 473 0 967
5639 2020-08-27 Nagaland 2611 9 3778
5640 2020-08-27 Odisha 62813 441 87602
5641 2020-08-27 Puducherry 7486 180 11930
5642 2020-08-27 Punjab 30231 1219 46090
5643 2020-08-27 Rajasthan 59579 992 74670
5644 2020-08-27 Sikkim 1076 3 1486
5645 2020-08-27 Tamil Nadu 338060 6839 397261
5646 2020-08-27 Telengana 86095 788 114483
5647 2020-08-27 Tripura 6697 85 9908
5648 2020-08-27 Uttarakhand 11524 219 16549
5649 2020-08-27 Uttar Pradesh 148562 3149 203028
5650 2020-08-27 West Bengal 117857 2964 147775

Most affected States

In [13]:
#Sorting data w.r.t number of confirmed cases
max_confirmed_cases=today.sort_values(by="confirmed",ascending=False)
max_confirmed_cases
Out[13]:
date state cured deaths confirmed
5635 2020-08-27 Maharashtra 522427 23089 718711
5645 2020-08-27 Tamil Nadu 338060 6839 397261
5617 2020-08-27 Andhra Pradesh 286720 3541 382469
5631 2020-08-27 Karnataka 211688 5091 300406
5649 2020-08-27 Uttar Pradesh 148562 3149 203028
5624 2020-08-27 Delhi 148897 4347 165764
5650 2020-08-27 West Bengal 117857 2964 147775
5620 2020-08-27 Bihar 106361 530 126714
5646 2020-08-27 Telengana 86095 788 114483
5619 2020-08-27 Assam 76962 274 96771
5626 2020-08-27 Gujarat 72282 2945 89994
5640 2020-08-27 Odisha 62813 441 87602
5643 2020-08-27 Rajasthan 59579 992 74670
5632 2020-08-27 Kerala 41690 257 64355
5627 2020-08-27 Haryana 47613 634 58005
5634 2020-08-27 Madhya Pradesh 43246 1282 56864
5642 2020-08-27 Punjab 30231 1219 46090
5629 2020-08-27 Jammu and Kashmir 26193 657 34480
5630 2020-08-27 Jharkhand 22349 362 33046
5622 2020-08-27 Chhattisgarh 14145 231 24550
5648 2020-08-27 Uttarakhand 11524 219 16549
5625 2020-08-27 Goa 11511 165 15027
5641 2020-08-27 Puducherry 7486 180 11930
5647 2020-08-27 Tripura 6697 85 9908
5636 2020-08-27 Manipur 3829 25 5585
5628 2020-08-27 Himachal Pradesh 3810 32 5321
5639 2020-08-27 Nagaland 2611 9 3778
5618 2020-08-27 Arunachal Pradesh 2563 5 3555
5621 2020-08-27 Chandigarh 1796 41 3376
5616 2020-08-27 Andaman and Nicobar Islands 2309 41 2985
5633 2020-08-27 Ladakh 1580 25 2451
5623 2020-08-27 Dadra and Nagar Haveli and Daman and Diu 1862 2 2228
5637 2020-08-27 Meghalaya 874 8 2050
5644 2020-08-27 Sikkim 1076 3 1486
5638 2020-08-27 Mizoram 473 0 967
In [14]:
#Getting states with maximum number of confirmed cases
top_states_confirmed=max_confirmed_cases[0:5]

Visualizing the top 5 most covid-19 affected states

In [15]:
#Making bar-plot for states with top confirmed cases
sns.set(rc={'figure.figsize':(15,10)})
sns.barplot(x="state",y="confirmed",data=top_states_confirmed,hue="state")
plt.show()
In [16]:
#Sorting data w.r.t number of death cases
max_death_cases=today.sort_values(by="deaths",ascending=False)
max_death_cases
Out[16]:
date state cured deaths confirmed
5635 2020-08-27 Maharashtra 522427 23089 718711
5645 2020-08-27 Tamil Nadu 338060 6839 397261
5631 2020-08-27 Karnataka 211688 5091 300406
5624 2020-08-27 Delhi 148897 4347 165764
5617 2020-08-27 Andhra Pradesh 286720 3541 382469
5649 2020-08-27 Uttar Pradesh 148562 3149 203028
5650 2020-08-27 West Bengal 117857 2964 147775
5626 2020-08-27 Gujarat 72282 2945 89994
5634 2020-08-27 Madhya Pradesh 43246 1282 56864
5642 2020-08-27 Punjab 30231 1219 46090
5643 2020-08-27 Rajasthan 59579 992 74670
5646 2020-08-27 Telengana 86095 788 114483
5629 2020-08-27 Jammu and Kashmir 26193 657 34480
5627 2020-08-27 Haryana 47613 634 58005
5620 2020-08-27 Bihar 106361 530 126714
5640 2020-08-27 Odisha 62813 441 87602
5630 2020-08-27 Jharkhand 22349 362 33046
5619 2020-08-27 Assam 76962 274 96771
5632 2020-08-27 Kerala 41690 257 64355
5622 2020-08-27 Chhattisgarh 14145 231 24550
5648 2020-08-27 Uttarakhand 11524 219 16549
5641 2020-08-27 Puducherry 7486 180 11930
5625 2020-08-27 Goa 11511 165 15027
5647 2020-08-27 Tripura 6697 85 9908
5616 2020-08-27 Andaman and Nicobar Islands 2309 41 2985
5621 2020-08-27 Chandigarh 1796 41 3376
5628 2020-08-27 Himachal Pradesh 3810 32 5321
5636 2020-08-27 Manipur 3829 25 5585
5633 2020-08-27 Ladakh 1580 25 2451
5639 2020-08-27 Nagaland 2611 9 3778
5637 2020-08-27 Meghalaya 874 8 2050
5618 2020-08-27 Arunachal Pradesh 2563 5 3555
5644 2020-08-27 Sikkim 1076 3 1486
5623 2020-08-27 Dadra and Nagar Haveli and Daman and Diu 1862 2 2228
5638 2020-08-27 Mizoram 473 0 967

Visualizing States with most number of deaths

In [17]:
#Getting states with maximum number of death cases
top_states_death=max_death_cases[0:5]
In [18]:
#Making bar-plot for states with top death cases
sns.set(rc={'figure.figsize':(15,10)})
sns.barplot(x="state",y="deaths",data=top_states_death,hue="state")
plt.show()

Visualizing the states with more covid recovery cases

In [19]:
#Sorting data w.r.t number of cured cases
max_cured_cases=today.sort_values(by="cured",ascending=False)
max_cured_cases
Out[19]:
date state cured deaths confirmed
5635 2020-08-27 Maharashtra 522427 23089 718711
5645 2020-08-27 Tamil Nadu 338060 6839 397261
5617 2020-08-27 Andhra Pradesh 286720 3541 382469
5631 2020-08-27 Karnataka 211688 5091 300406
5624 2020-08-27 Delhi 148897 4347 165764
5649 2020-08-27 Uttar Pradesh 148562 3149 203028
5650 2020-08-27 West Bengal 117857 2964 147775
5620 2020-08-27 Bihar 106361 530 126714
5646 2020-08-27 Telengana 86095 788 114483
5619 2020-08-27 Assam 76962 274 96771
5626 2020-08-27 Gujarat 72282 2945 89994
5640 2020-08-27 Odisha 62813 441 87602
5643 2020-08-27 Rajasthan 59579 992 74670
5627 2020-08-27 Haryana 47613 634 58005
5634 2020-08-27 Madhya Pradesh 43246 1282 56864
5632 2020-08-27 Kerala 41690 257 64355
5642 2020-08-27 Punjab 30231 1219 46090
5629 2020-08-27 Jammu and Kashmir 26193 657 34480
5630 2020-08-27 Jharkhand 22349 362 33046
5622 2020-08-27 Chhattisgarh 14145 231 24550
5648 2020-08-27 Uttarakhand 11524 219 16549
5625 2020-08-27 Goa 11511 165 15027
5641 2020-08-27 Puducherry 7486 180 11930
5647 2020-08-27 Tripura 6697 85 9908
5636 2020-08-27 Manipur 3829 25 5585
5628 2020-08-27 Himachal Pradesh 3810 32 5321
5639 2020-08-27 Nagaland 2611 9 3778
5618 2020-08-27 Arunachal Pradesh 2563 5 3555
5616 2020-08-27 Andaman and Nicobar Islands 2309 41 2985
5623 2020-08-27 Dadra and Nagar Haveli and Daman and Diu 1862 2 2228
5621 2020-08-27 Chandigarh 1796 41 3376
5633 2020-08-27 Ladakh 1580 25 2451
5644 2020-08-27 Sikkim 1076 3 1486
5637 2020-08-27 Meghalaya 874 8 2050
5638 2020-08-27 Mizoram 473 0 967
In [20]:
#Getting states with maximum number of cured cases
top_states_cured=max_cured_cases[0:5]
In [21]:
#Making bar-plot for states with top death cases
sns.set(rc={'figure.figsize':(15,10)})
sns.barplot(x="state",y="cured",data=top_states_cured,hue="state")
plt.show()

Analysing Different states reports

In [22]:
TN = df[df['state'] == 'Tamil Nadu']
In [23]:
TN
Out[23]:
date state cured deaths confirmed
61 2020-03-07 Tamil Nadu 0 0 1
67 2020-03-08 Tamil Nadu 0 0 1
79 2020-03-09 Tamil Nadu 0 0 1
94 2020-03-10 Tamil Nadu 0 0 1
105 2020-03-11 Tamil Nadu 0 0 1
... ... ... ... ... ...
5505 2020-08-23 Tamil Nadu 313280 6420 373410
5540 2020-08-24 Tamil Nadu 319327 6517 379385
5575 2020-08-25 Tamil Nadu 325456 6614 385352
5610 2020-08-26 Tamil Nadu 332454 6721 391303
5645 2020-08-27 Tamil Nadu 338060 6839 397261

174 rows × 5 columns

visualizing the confirmed cases of Tamil Nadu

In [69]:
#Visualizing confirmed cases in Tamil Nadu
sns.set(rc={'figure.figsize':(15,10)})
sns.lineplot(x="date",y="confirmed",data=TN,color="g")
plt.show()
In [25]:
#Visualizing death cases in Tamil Nadu
sns.set(rc={'figure.figsize':(15,10)})
sns.lineplot(x="date",y="deaths",data=TN,color="r")
plt.show()
In [26]:
#kerala
kerala= df[df['state'] == 'Kerala']
kerala
Out[26]:
date state cured deaths confirmed
0 2020-01-30 Kerala 0 0 1
1 2020-01-31 Kerala 0 0 1
2 2020-02-01 Kerala 0 0 2
3 2020-02-02 Kerala 0 0 3
4 2020-02-03 Kerala 0 0 3
... ... ... ... ... ...
5492 2020-08-23 Kerala 36535 218 56354
5527 2020-08-24 Kerala 37645 223 58262
5562 2020-08-25 Kerala 38883 234 59504
5597 2020-08-26 Kerala 40339 244 61879
5632 2020-08-27 Kerala 41690 257 64355

211 rows × 5 columns

In [27]:
#Visualizing confirmed cases in Kerala
sns.set(rc={'figure.figsize':(15,10)})
sns.lineplot(x="date",y="confirmed",data=kerala,color="g")
plt.show()
In [28]:
#Visualizing death cases in Kerala
sns.set(rc={'figure.figsize':(15,10)})
sns.lineplot(x="date",y="deaths",data=kerala,color="r")
plt.show()
In [29]:
#Jammu and Kashmir
jk= df[df['state'] == 'Jammu and Kashmir']
jk
Out[29]:
date state cured deaths confirmed
81 2020-03-09 Jammu and Kashmir 0 0 1
96 2020-03-10 Jammu and Kashmir 0 0 1
106 2020-03-11 Jammu and Kashmir 0 0 1
117 2020-03-12 Jammu and Kashmir 0 0 1
130 2020-03-13 Jammu and Kashmir 0 0 1
... ... ... ... ... ...
5489 2020-08-23 Jammu and Kashmir 24398 608 31981
5524 2020-08-24 Jammu and Kashmir 24832 617 32647
5559 2020-08-25 Jammu and Kashmir 25205 624 33075
5594 2020-08-26 Jammu and Kashmir 25594 638 33776
5629 2020-08-27 Jammu and Kashmir 26193 657 34480

172 rows × 5 columns

In [30]:
#Visualizing confirmed cases in Jammu and Kashmir
sns.set(rc={'figure.figsize':(15,10)})
sns.lineplot(x="date",y="confirmed",data=jk,color="g")
plt.show()
In [31]:
#Visualizing death cases in Jammu and Kashmir
sns.set(rc={'figure.figsize':(15,10)})
sns.lineplot(x="date",y="deaths",data=jk,color="r")
plt.show()

Testing Details of State/UT:

In [32]:
#Checking state-wise testing details
tests = pd.read_csv('https://cainvas-static.s3.amazonaws.com/media/user_data/AnandKumarE0/StatewiseTestingDetails.csv')
tests
Out[32]:
Date State TotalSamples Negative Positive
0 2020-04-17 Andaman and Nicobar Islands 1403.0 1210 12.0
1 2020-04-24 Andaman and Nicobar Islands 2679.0 NaN 27.0
2 2020-04-27 Andaman and Nicobar Islands 2848.0 NaN 33.0
3 2020-05-01 Andaman and Nicobar Islands 3754.0 NaN 33.0
4 2020-05-16 Andaman and Nicobar Islands 6677.0 NaN 33.0
... ... ... ... ... ...
4532 2020-08-21 West Bengal 1487844.0 NaN 132364.0
4533 2020-08-22 West Bengal 1524162.0 NaN 135596.0
4534 2020-08-23 West Bengal 1561311.0 NaN NaN
4535 2020-08-24 West Bengal 1596578.0 NaN NaN
4536 2020-08-25 West Bengal 1634102.0 NaN NaN

4537 rows × 5 columns

In [33]:
test_latest =  tests[tests.Date == '2020-08-25']
In [34]:
test_latest
Out[34]:
Date State TotalSamples Negative Positive
240 2020-08-25 Andhra Pradesh 3356852.0 2985213 NaN
368 2020-08-25 Arunachal Pradesh 149273.0 141127 NaN
487 2020-08-25 Assam 2035216.0 NaN NaN
626 2020-08-25 Bihar 2570097.0 NaN NaN
764 2020-08-25 Chandigarh 26348.0 22934 NaN
896 2020-08-25 Chhattisgarh 505193.0 NaN NaN
1150 2020-08-25 Delhi 1462845.0 NaN NaN
1283 2020-08-25 Goa 184872.0 NaN NaN
1422 2020-08-25 Gujarat 1891775.0 NaN 88942.0
1564 2020-08-25 Haryana 1001781.0 938914 56608.0
1702 2020-08-25 Himachal Pradesh 198010.0 192044 NaN
1841 2020-08-25 Jammu and Kashmir 888127.0 854351 NaN
1976 2020-08-25 Jharkhand 600322.0 568148 NaN
2117 2020-08-25 Karnataka 2513555.0 NaN NaN
2264 2020-08-25 Kerala 1484907.0 NaN 61880.0
2363 2020-08-25 Ladakh 27735.0 21217 NaN
2505 2020-08-25 Madhya Pradesh 1226559.0 1166480 NaN
2646 2020-08-25 Maharashtra 3711123.0 2994256 NaN
2735 2020-08-25 Manipur 137384.0 NaN NaN
2845 2020-08-25 Meghalaya 76762.0 74293 NaN
2978 2020-08-25 Mizoram 35214.0 NaN NaN
3114 2020-08-25 Nagaland 57426.0 NaN NaN
3256 2020-08-25 Odisha 1421958.0 NaN 84231.0
3385 2020-08-25 Puducherry 67301.0 53950 NaN
3526 2020-08-25 Punjab 941939.0 NaN NaN
3668 2020-08-25 Rajasthan 2166744.0 2091316 NaN
3777 2020-08-25 Sikkim 38296.0 NaN NaN
3918 2020-08-25 Tamil Nadu 4346861.0 NaN NaN
3991 2020-08-25 Telangana 1021054.0 NaN 108670.0
4112 2020-08-25 Tripura 247299.0 238089 9210.0
4252 2020-08-25 Uttar Pradesh 4796488.0 NaN NaN
4393 2020-08-25 Uttarakhand 325384.0 288263 NaN
4536 2020-08-25 West Bengal 1634102.0 NaN NaN

States conducts more number of testing:

In [35]:
#Sorting data w.r.t number of cured cases
max_tests_State=test_latest.sort_values(by="TotalSamples",ascending=False)
max_tests_State
Out[35]:
Date State TotalSamples Negative Positive
4252 2020-08-25 Uttar Pradesh 4796488.0 NaN NaN
3918 2020-08-25 Tamil Nadu 4346861.0 NaN NaN
2646 2020-08-25 Maharashtra 3711123.0 2994256 NaN
240 2020-08-25 Andhra Pradesh 3356852.0 2985213 NaN
626 2020-08-25 Bihar 2570097.0 NaN NaN
2117 2020-08-25 Karnataka 2513555.0 NaN NaN
3668 2020-08-25 Rajasthan 2166744.0 2091316 NaN
487 2020-08-25 Assam 2035216.0 NaN NaN
1422 2020-08-25 Gujarat 1891775.0 NaN 88942.0
4536 2020-08-25 West Bengal 1634102.0 NaN NaN
2264 2020-08-25 Kerala 1484907.0 NaN 61880.0
1150 2020-08-25 Delhi 1462845.0 NaN NaN
3256 2020-08-25 Odisha 1421958.0 NaN 84231.0
2505 2020-08-25 Madhya Pradesh 1226559.0 1166480 NaN
3991 2020-08-25 Telangana 1021054.0 NaN 108670.0
1564 2020-08-25 Haryana 1001781.0 938914 56608.0
3526 2020-08-25 Punjab 941939.0 NaN NaN
1841 2020-08-25 Jammu and Kashmir 888127.0 854351 NaN
1976 2020-08-25 Jharkhand 600322.0 568148 NaN
896 2020-08-25 Chhattisgarh 505193.0 NaN NaN
4393 2020-08-25 Uttarakhand 325384.0 288263 NaN
4112 2020-08-25 Tripura 247299.0 238089 9210.0
1702 2020-08-25 Himachal Pradesh 198010.0 192044 NaN
1283 2020-08-25 Goa 184872.0 NaN NaN
368 2020-08-25 Arunachal Pradesh 149273.0 141127 NaN
2735 2020-08-25 Manipur 137384.0 NaN NaN
2845 2020-08-25 Meghalaya 76762.0 74293 NaN
3385 2020-08-25 Puducherry 67301.0 53950 NaN
3114 2020-08-25 Nagaland 57426.0 NaN NaN
3777 2020-08-25 Sikkim 38296.0 NaN NaN
2978 2020-08-25 Mizoram 35214.0 NaN NaN
2363 2020-08-25 Ladakh 27735.0 21217 NaN
764 2020-08-25 Chandigarh 26348.0 22934 NaN

visualizing the top 5 states where more testings done.

In [36]:
#Making bar-plot for states with max test cases
sns.set(rc={'figure.figsize':(15,10)})
sns.barplot(x="State",y="TotalSamples",data=max_tests_State[0:5],hue="State")
plt.show()

Predicting the covid 19 cases using Facebook's Prophet

Prophet is open source software released by Facebook’s Core Data Science team. It is available for download on CRAN and PyPI.

We use Prophet, a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well

In [37]:
from fbprophet import Prophet
Importing plotly failed. Interactive plots will not work.
In [38]:
confirmed = df.groupby('date').sum()['confirmed'].reset_index()
deaths = df.groupby('date').sum()['deaths'].reset_index()
recovered = df.groupby('date').sum()['cured'].reset_index()
In [39]:
confirmed.tail()
Out[39]:
date confirmed
206 2020-08-23 3044940
207 2020-08-24 3106348
208 2020-08-25 3167323
209 2020-08-26 3234474
210 2020-08-27 3310234

Predicting the Confirmed Cases:

In [40]:
confirmed.columns = ['ds','y']
#confirmed['ds'] = confirmed['ds'].dt.date
confirmed['ds'] = pd.to_datetime(confirmed['ds'])
In [55]:
m = Prophet(interval_width=0.95)
m.fit(confirmed)
future = m.make_future_dataframe(periods=30)
future.tail()
INFO:fbprophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this.
INFO:fbprophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
Out[55]:
ds
236 2020-09-22
237 2020-09-23
238 2020-09-24
239 2020-09-25
240 2020-09-26
In [56]:
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
Out[56]:
ds yhat yhat_lower yhat_upper
236 2020-09-22 4.614932e+06 4.443216e+06 4.815456e+06
237 2020-09-23 4.670349e+06 4.493096e+06 4.861481e+06
238 2020-09-24 4.725979e+06 4.538310e+06 4.942200e+06
239 2020-09-25 4.777488e+06 4.581122e+06 5.011385e+06
240 2020-09-26 4.833050e+06 4.621831e+06 5.069164e+06

plotting the prediction of confirmed cases

In [57]:
confirmed_forecast_plot = m.plot(forecast)

The blue datapoints are the original values and the blue line represents the forecast values.

In [58]:
confirmed_forecast_plot =m.plot_components(forecast)

Prediction of Deaths

In [59]:
deaths.columns = ['ds','y']
deaths['ds'] = pd.to_datetime(deaths['ds'])
In [60]:
m = Prophet(interval_width=0.95)
m.fit(deaths)
future = m.make_future_dataframe(periods=30)
future.tail()
INFO:fbprophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this.
INFO:fbprophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
Out[60]:
ds
236 2020-09-22
237 2020-09-23
238 2020-09-24
239 2020-09-25
240 2020-09-26
In [61]:
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
Out[61]:
ds yhat yhat_lower yhat_upper
236 2020-09-22 80835.951728 77659.208578 84063.523346
237 2020-09-23 81738.572762 78311.225679 84922.327423
238 2020-09-24 82587.499907 79073.561847 86010.850909
239 2020-09-25 83381.307968 79827.117332 86982.303228
240 2020-09-26 84214.075618 80276.815029 88201.619111
In [62]:
deaths_forecast_plot = m.plot(forecast)

The blue datapoints are the original values and the blue line represents the forecast values. From the above prediction it shows that the covid death cases continue to increase at the same rate for the next 30 days.

In [63]:
deaths_forecast_plot = m.plot_components(forecast)

trends of the predicted cases.

Predicting the recovery of the cases

In [64]:
recovered.columns = ['ds','y']
recovered['ds'] = pd.to_datetime(recovered['ds'])
In [65]:
m = Prophet(interval_width=0.95)
m.fit(recovered)
future = m.make_future_dataframe(periods=30)
future.tail()
INFO:fbprophet:Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this.
INFO:fbprophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
Out[65]:
ds
236 2020-09-22
237 2020-09-23
238 2020-09-24
239 2020-09-25
240 2020-09-26
In [66]:
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
Out[66]:
ds yhat yhat_lower yhat_upper
236 2020-09-22 3.481910e+06 3.300941e+06 3.630402e+06
237 2020-09-23 3.527244e+06 3.342520e+06 3.693280e+06
238 2020-09-24 3.571000e+06 3.375948e+06 3.745915e+06
239 2020-09-25 3.609656e+06 3.411769e+06 3.790962e+06
240 2020-09-26 3.653656e+06 3.448073e+06 3.852695e+06
In [67]:
recovered_forecast_plot = m.plot(forecast)

The blue datapoints are the original values and the blue line represents the forecast values.

In [68]:
recovered_forecast_plot = m.plot_components(forecast)

From the above observations we can clearly state that the predictions of cases ,recovery, and death rates for the next 30 days seems to be rising at the same rate as it was before.

So please maintain Social distancing and always wear mask and wash your hands regularly.