Covid19 Machine Learning Prediction and Forecasting | Time Series Analysis

--

On day one, no one you know is sick. It feels like a normal day. But then one day, a few people you know are sick and suddenly, you see everyone is sick and it will feel like it happened so instantly. Everything looks fine until it isn’t. This is the paradox of pandemics. In this article, we shall analyse the outbreak of COVID-19 using Machine Learning.

What is COVID-19?

The Problem

Corona Virus disease (COVID-19) is an infectious disease caused by a newly discovered virus, which emerged in Wuhan, China in December of 2019.

Most people infected with the COVID-19 virus will experience mild to moderate respiratory illness and recover without requiring special treatment. Older people and those with underlying medical problems like cardiovascular disease, diabetes, chronic respiratory disease, and cancer are more likely to develop serious illness.

The COVID-19 virus spreads primarily through droplets of saliva or discharge from the nose when an infected person coughs or sneezes, so you might have heard caution to practice respiratory etiquette (for example, by coughing into a flexed elbow).

How does a Pandemic Work?

To understand this better let’s look a small riddle.

There’s a glass slide held under a microscope which consists of a specific germ. This germ has a property to double every day. So on the first day, there’s one, on the second day there are two, on the third day there four and the fourth day eight, and so on.

A germ doubles everyday.

On the 60th day, the slide is full. So on which day is the slide half full?

Day 59. But of course, you knew that.

But on which day, is the slide 1% full?

Surprisingly, not until the 54th day!

What it means that the slide goes from being 1% full to 100% in less than a week and hence, displays a property called exponential growth. And this is also how a Pandemic works. The outbreak is fairly unnoticeable in the beginning, then, once it reaches a significant value, the growth to maxima is extremely quick.

This is known as Exponential growth!

But it cannot go on forever. The virus will eventually stop finding people to infect and ultimate will slow down the count. This is called logistic growth and the curve is known as a sigmoid.

We eventually end up with sigmoid.

Now every point in the curve will give you to running total of cases of the current day. But if you delve a little into statistics, you’ll discover that by plotting the slope of each day, you shall get the new cases per day. There are fewer new cases right at the beginning and at the end, with a sharp rise in the stages in between.

The curve obtained if you calculate the slop against each point of the sigmoid.

As you can see, the peak of the curve may greatly overwhelm our healthcare systems, which is the amount of resources available to us for the care of affected individuals at any given point in time.

Since we can’t really help the total number of individuals affected by the pandemic, the best solution is to flatten the curve so as to bring down the total number of cases, at any given point in time, as close to the healthcare line as possible.

The only solution is to flatten the curve.

This spreads the duration of this whole process a little longer, but since the healthcare system can tend to the number of cases at any given point in time, the casualties are way lower.

The Solution

Social Distancing. The logic here is, the virus can’t infect bodies if it cannot find bodies to infect!

World Leaders in all affected countries announced quarantines and lock-downs to keep their folks safe and away from anything or anyone that could infect them, all big social events were postponed and all major sports leagues cancelled as well.

On March 24, the Indian Prime Minister announced that the country would go under a lock-down to combat the spread of the virus, until further notice. Infections are rapidly rising in Italy, France, Germany, Spain, the United Kingdom and the United States. It has has a massive impact on the global economy and stock markets

The outbreak of COVID-19 is developing into a major international crisis, and it’s starting to influence important aspects of daily life.

For example:

  • Travel: Complete lock-down no domestic or international flights are allowed in India until decided by Ministry of Civil Aviation.
  • Grocery stores: In highly affected areas, people are starting to stock up on essential goods leading to a shortage of essentials.

You can also take a look at the following tutorial on “COVID 19 Outbreak Prediction using Machine Learning” to get to know the subject in a way more comprehensive manner.

COVID — 19 Outbreak Prediction using Machine Learning

Import below library for data analysis, data visualization, prediction and forecasting.

Now read data from “covid_19_data.csv” file.

Output of reading csv file.

Now, we check the size, shape and datatype of dataset.

Shape, size and datatype of dataset.

Now, we are going to drop SNo from dataset using drop method because I don’t need SNo.

Now, we can see that SNo is vanished by running bellow code.

SNo is vanished.

Now, we are going to convert datetime format.

Now, we are going to group of different types of cases as per the date.

Now, we print basic information like confirmed, recovered and deaths.

Basic Information like confirmed, recovered and deaths.

Now, we are going to visualize active cases using graph as per date.

Now, we are going to visualize closed cases using graph as per date.

Now, we are going to visualize weekly increase in covid19 cases.

Weekly visualization of increase and decrease in cases using bar graph.

Now, we are going to visualize average increase in number of cases everyday as per date.

Now, we are going to do country wise analysis and calculating mortality rate.

Now, we are going to analyse the data of india.

Now, we are going to predict week wise confirmed, recovered and deaths cases for india.

Now, we are going to predict how much time india, spain, china, italy and us take to reach particular cases.

COVID — 19 Forecasting

Now, we are going to initialize our model.

Now, we are going to forecast using linear regression and SVR.

Now, we are going to go for prediction.

Now, we are going to see the scores.

Now, we are going to forecast using time series analysis.

Summary

I learned how to analyse, predict and forecast data using linear regression and time series analysis using machine learning.

I hope you enjoyed this project.

Source Code

--

--