0% found this document useful (0 votes)
19 views

Covid-19 Deaths Prediction With Machine Learning

This article describes how to use machine learning to predict COVID-19 deaths based on historical case and death data. The author cleans and analyzes the data, calculating the death rate. An AutoTS model is trained on the data and predicts COVID-19 deaths for the next 30 days, outputting forecasts with uncertainty intervals. In summary, machine learning can leverage past case and death trends to predict future COVID-19 mortality.

Uploaded by

kranti29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Covid-19 Deaths Prediction With Machine Learning

This article describes how to use machine learning to predict COVID-19 deaths based on historical case and death data. The author cleans and analyzes the data, calculating the death rate. An AutoTS model is trained on the data and predicts COVID-19 deaths for the next 30 days, outputting forecasts with uncertainty intervals. In summary, machine learning can leverage past case and death trends to predict future COVID-19 mortality.

Uploaded by

kranti29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

7/7/23, 9:55 PM Covid-19 Deaths Prediction with Machine Learning | Aman Kharwal

Covid-19 Deaths Prediction with Machine


Learning
AMAN KHARWAL / MARCH 29, 2022 / MACHINE LEARNING / 4

Covid-19 is one of the deadliest viruses you’ve ever heard.


Mutations in covid-19 make it either more deadly or more
infectious. We have seen a lot of deaths from covid-19 while
there is a higher wave of cases. We can use historical data on
covid-19 cases and deaths to predict the number of deaths in
the future. So if you want to learn how to predict covid-19 deaths
with machine learning, this article is for you. In this article, I will
take you through the task of Covid-19 deaths prediction with
machine learning using Python.

Covid-19 Deaths Prediction (Case


Study)
You are given a dataset of Covid-19 in India from 30 January
2020 to 18 January 2022. The dataset contains information
about the daily confirmed cases and deaths. Below are all the
columns of the dataset:

https://thecleverprogrammer.com/2022/03/29/covid-19-deaths-prediction-with-machine-learning/ 1/12
7/7/23, 9:55 PM Covid-19 Deaths Prediction with Machine Learning | Aman Kharwal

1. Date: Contains the date of the record


2. Date_YMD: Contains date in Year-Month-Day Format
3. Daily Confirmed: Contains the daily confirmed cases of
Covid-19
4. Daily Deceased: Contains the daily deaths due to Covid-19

You need to use this historical data of covid-19 cases and


deaths to predict the number of deaths for the next 30 days. You
can download this dataset from here.

Covid-19 Deaths Prediction using


Python
I hope you now have understood the problem statement
mentioned above. Now I will import all the necessary Python
libraries and the dataset we need for the task of covid-19 deaths
prediction:

1 import pandas as pd
2 import numpy as np
3 data = pd.read_csv("COVID19 data for overall INDIA
4 print(data.head())

Date Date_YMD Daily Confirmed Daily Deceased


0 30 January 2020 2020-01-30 1 0
1 31 January 2020 2020-01-31 0 0
2 1 February 2020 2020-02-01 0 0
3 2 February 2020 2020-02-02 1 0
4 3 February 2020 2020-02-03 1 0

https://thecleverprogrammer.com/2022/03/29/covid-19-deaths-prediction-with-machine-learning/ 2/12
7/7/23, 9:55 PM Covid-19 Deaths Prediction with Machine Learning | Aman Kharwal

Before moving forward, let’s have a quick look at whether this


dataset contains any null values or not:

1 data.isnull().sum()

Date 0
Date_YMD 0
Daily Confirmed 0
Daily Deceased 0
dtype: int64

We don’t need the date column, so let’s drop this column from
our dataset:

1 data = data.drop("Date", axis=1)

Let’s have a look at the daily confirmed cases of Covid-19:

1 import plotly.express as px
2 fig = px.bar(data, x='Date_YMD', y='Daily Confirme
3 fig.show()

https://thecleverprogrammer.com/2022/03/29/covid-19-deaths-prediction-with-machine-learning/ 3/12
7/7/23, 9:55 PM Covid-19 Deaths Prediction with Machine Learning | Aman Kharwal

In the data visualization above, we can see a high wave of


covid-19 cases between April 2021 and May 2021.

Covid-19 Death Rate Analysis


Now let’s visualize the death rate due to Covid-19:

1 cases = data["Daily Confirmed"].sum()


2 deceased = data["Daily Deceased"].sum()
3 ​
4 labels = ["Confirmed", "Deceased"]
5 values = [cases, deceased]
6 ​
7 fig = px.pie(data, values=values,
8 names=labels,
9 title='Daily Confirmed Cases vs Daily

https://thecleverprogrammer.com/2022/03/29/covid-19-deaths-prediction-with-machine-learning/ 4/12
7/7/23, 9:55 PM Covid-19 Deaths Prediction with Machine Learning | Aman Kharwal

10 fig.show()

Let’s calculate the death rate of Covid-19:

1 death_rate = (data["Daily Deceased"].sum() / data[


2 print(death_rate)

1.2840580507834722

Now let’s have a look at the daily deaths of covid-19:

1 import plotly.express as px
2 fig = px.bar(data, x='Date_YMD', y='Daily Deceased
3 fig.show()

https://thecleverprogrammer.com/2022/03/29/covid-19-deaths-prediction-with-machine-learning/ 5/12
7/7/23, 9:55 PM Covid-19 Deaths Prediction with Machine Learning | Aman Kharwal

We can see a high number of deaths during the high wave of


covid-19 cases.

Covid-19 Deaths Prediction Model


Now let’s move to the task of covid-19 deaths prediction for the
next 30 days. Here I will be using the AutoTS library, which is
one of the best Automatic Machine Learning libraries for Time
Series Analysis. If you have never used this library before, you
can install it by executing the command mentioned below in your
command prompt or terminal:

pip install autots

Now here’s how to predict covid-19 deaths with machine


learning for the next 30 days:
https://thecleverprogrammer.com/2022/03/29/covid-19-deaths-prediction-with-machine-learning/ 6/12
7/7/23, 9:55 PM Covid-19 Deaths Prediction with Machine Learning | Aman Kharwal

1 from autots import AutoTS


2 model = AutoTS(forecast_length=30, frequency='infe
3 model = model.fit(data, date_col="Date_YMD", value
4 prediction = model.predict()
5 forecast = prediction.forecast
6 print(forecast)

Daily Deceased
2022-01-19 271.950000
2022-01-20 310.179787
2022-01-21 297.500000
2022-01-22 310.179787
2022-01-23 271.950000
2022-01-24 258.518302
2022-01-25 340.355520
2022-01-26 296.561343
2022-01-27 296.561343
2022-01-28 284.438262
2022-01-29 323.400000
2022-01-30 271.950000
2022-01-31 245.750000
2022-02-01 284.438262
2022-02-02 258.518302
2022-02-03 239.969607
2022-02-04 271.950000
2022-02-05 334.118953
2022-02-06 323.400000
2022-02-07 271.950000
2022-02-08 284.438262
2022-02-09 323.400000
2022-02-10 258.518302
2022-02-11 245.750000
2022-02-12 245.750000
2022-02-13 326.442185
2022-02-14 323.400000
2022-02-15 394.343619

https://thecleverprogrammer.com/2022/03/29/covid-19-deaths-prediction-with-machine-learning/ 7/12
7/7/23, 9:55 PM Covid-19 Deaths Prediction with Machine Learning | Aman Kharwal

2022-02-16 228.117431
2022-02-17 358.200000

Summary
So this is how we can predict covid-19 deaths with machine
learning using the Python programming language. We can use
the historical data of covid-19 cases and deaths to predict the
number of deaths in future. You can implement the same
method for predicting covid-19 deaths and waves on the latest
dataset. I hope you liked this article on covid-19 deaths
prediction with machine learning. Feel free to ask valuable
questions in the comments section below.

Aman Kharwal

I'm a writer and data scientist on a mission to educate others


about the incredible power of data📈.

ARTICLES: 1451

https://thecleverprogrammer.com/2022/03/29/covid-19-deaths-prediction-with-machine-learning/ 8/12

You might also like