Analysing, Visualising, and Forecasting of Covid-19 Spread in India Using Python
Currently, there is a lot of visualization and statistics available about the Coronavirus spread all over the internet. With so much information and expert opinions, It is difficult to analyze the information and its impact on situations. For example, different nations are adopting different strategies to implement lockdowns, following social distancing norms in affected areas, and so on. There is no straight solution available to resolve the current situation as it also depends on many other factors to handle the situation carefully. This article is an attempt of forecasting and analyze Coronavirus (COVID-19) spread in India.
Introduction
Coronavirus is an RNA (Ribonucleic acid)virus consisting of positive-sense single-stranded RNA of approximately 27–32 kb. Coronavirus belongs to the family Coronaviridae, which comprises of alpha, beta, delta, and gamma coronaviruses. The virus is known to infect a wide range of hosts including humans, other mammals, and birds. In India, 1.34 billion people have been following lockdown, maintaining social distancing and other precautions as per guidelines issued by Government of India. Therefore, I have tried to cover impact of COVID-19 on Indian population.
Objective
The objective of this article is toget the required datafor analysis andgain visibilityon COVID-19 by enabling the gathering of all relevant data.
Table of Contents
Technical Prerequisites
Gather COVID-19 Data
State Wise Mortality Rate In India
State Wise Analysis Before and After Lockdown
Active Case Forecasting
Confirmed Case Forecasting
Prerequisites
Have Python 3.1 or above version installed
Install Pandas, Plotly, Maltplotlib, Scikit-learn
Gather COVID-19 data
With various attempt to clamp down the effect of COVID-19 on the world, various research works and innovative measures depends on insights gained from the right data, so i decided to useCovid19IndiaAPI,below is the code for fetching state wise details from the api.
Above code,specified below details
2 sources of Datalatestandstate_wise_daily
Mapped State code with State Names
Aggregated and sorting of data day wise
So now we have the aggregated day by day states number ofconfirmed,deceasedandrecovered cases.
State Wise Mortality Rate in India
For finding Mortality Rate per 100 people use below code.
Above we have aggregated sum data for the states and for finding mortality rate, we divide deceased case with confirmed case and after running the code you will find below output
From the output we can analyse thatGujarat, MaharashtraandMadhya Pradeshare the major state where in each 100 confirmed cases of Covid-19 approx.5 casescoming underdeceased.
State wise analysis Before and after Lockdown
For doing state wise analysis , analysed the first phase of lockdown period started from24-Mar-2020to24-Apr-2020. Below are few snaps for state wise trend.
It’s interesting thathow after lockdownrecovered and confirmed casesare increasing insimilar patternfor all the states .You can use below code to get above visualisation.
Now, we will aggregate theconfirmed cases day count wise to get the visual representation.
Since the first identified case of Covid-19 in India, we are now on 104th day and analysis shows that the bar is increasing day by day. Below is the code for getting above visualisation.
Instead of dwelling on the exact numbers, the takeaway message from below forecasting is that we can draw a meaningful analysis and takepre-actions.
Active Case Forecasting
Analysis shows thatdailyActivecasesin India is approx.4524and on day 52 the curve stoppedsteepeningand startedflatten, curve will flatten tillday 130which is22 July 2020 .Also, On31 July 2020 ,India have approx360848 Active casesof Covid-19. You can use below code for getting above analysis before that letsunderstand sigmoid function in our scenario.
Sigmoid Function
From small beginnings that accelerates and approaches a climax over time, When a specific mathematical model is lacking, a sigmoid function is often used. So in our case sigmoid function isy = c/(1+np.exp(-a*(x-b)))where c —Maximum value (Maximum Infected people from Virus) a —Sigmoidal shape (how the infection progress) b —Point where sigmoid start to flatten
Below is the code for sigmoid function and Active Case Forecasting
The trick to make this understanding that this is not an actual linear process, but an exponential one. We must treat our data accordingly.
Confirmed Case Forecasting
DailyConfirmedcasesin India is approx.29115and on day 94 the curve stoppedsteepeningand startedflatten, curve will flatten tillday 245which is14 November 2020.Also, On31 July 2020 ,India have approx.1276800 Confirmed casesof Covid-19. You can use below code for getting above analysis.
I hope this article aid furtherance of research works. Thanks for reading. Stay safe!