Analysing ,Visualising and Forecasting of Covid-19 Spread in India using Python
By: Ravi Pandey
Tags: Covid 19, Python, Machine Learning, Coronavirus Update, Data Science

Analysing ,Visualising and Forecasting of Covid-19 Spread in India using Python

Currently, there are lot of visualisation and statistics available around the Coronavirus spread all over the internet. With so much information and expert opinions, It is difficult to analyse the information and its impact on situations. For example, different nations are adopting different strategies to implement lockdown, 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 analysing 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 to get the required data for analysis and gain visibility on 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 use Covid19India API, below is the code for fetching state wise details from the api.

Above code, specified below details

2 sources of Data latest and state_wise_daily

and Mapped State code with State Names

Aggregated and sorting of data day wise

So now we have the aggregated day by day states number of confirmed , deceased and recovered 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

State Wise Mortality Rate Per 100 (Last Updated: 27-Jun-2020)

From the output we can analyse that Gujarat, Maharashtra and Madhya Pradesh are the major state where in each 100 confirmed cases of Covid-19 approx. 5 cases coming under deceased.

State wise analysis Before and after Lockdown

For doing state wise analysis , analysed the first phase of lockdown period started from 24-Mar-2020 to 24-Apr-2020 . Below are few snaps for state wise trend.

Evolution of Confirmed-Recovered-Deceased Cases in Delhi (last updated: 27-jun-2020)

Evolution of Confirmed-Recovered-Deceased Cases in Maharashtra (last updated: 28-jun-2020)

It’s interesting that how after lockdown recovered and confirmed cases are increasing in similar pattern for all the states .You can use below code to get above visualisation.

Now, we will aggregate the confirmed cases day count wise to get the visual representation.

Evaluation of Confirmed cases on no of Days (last updated: 26-June-2020)

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 take pre-actions .

Active Case Forecasting

Active Case Forecasting

Analysis shows that daily Active cases in India is approx. 4524 and on day 52 the curve stopped steepening and started flatten , curve will flatten till day 130 which is 22 July 2020 . Also, On 31 July 2020 , India have approx 360848 Active cases of Covid-19. You can use below code for getting above analysis before that lets understand 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 is y = 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

Sigmoid Function

The trick to make this understanding that this is not an actual linear process, but an exponential one. We must treat our data accordingly.

Active Case Forecasting

Confirmed Case Forecasting

Daily Confirmed cases in India is approx. 29115 and on day 94 the curve stopped steepening and started flatten , curve will flatten till day 245 which is 14 November 2020. Also, On 31 July 2020 , India have approx. 1276800 Confirmed cases of 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!

References

Covid19India.org

Identification of Coronavirus Isolated from a Patient

Special Thanks to Priyanka and Nikhil!