A.I, Data and Software Engineering

Predict coronavirus deaths by days

P

As the pandemic is going on with an increasing number of deaths daily, let create a simple model to predict the deaths caused by 2019-nCoV (Wuhan Coronavirus).

Coronavirus outbreak

The 2019-nCoV death data

I grab the death toll data from World Meters website.

DateDaily Deaths
Feb. 889
Feb. 786
Jan. 2416
Jan. 238

Plot the data

Firstly, we transform the table into a Pandas data frame.

Then we can have a look at the following graph

2019-nCov death
2019-nCoV death toll

We can see that a linear regression model could be a good choice at this stage. Since we only have a very small data set (17 samples), it may not reflect correctly the trend. However, in this article, we want to implement with polynomial regression. Let review some terms:

Regression

Regression is about finding the trend in data (the relationship between variables). This allows us to better understand the data distribution and to predict the values for new input variables. The regression outputs continuous values (real values) to distinguish classification which predicts discrete values.

Linear Regression

Linear regression is used when the trend in the data is linear, i.e., it is of the form y = ax + b The other, more commonly used form of regression is polynomial regression.

Polynomial Regression

Polynomial regression used when the trend in data is a polynomial of degree ’n’, i.e., it is of the form \(y = a_0x^n + a_1x^{n-1}+ … + a_n\).

Keras implementation

First, we import relevant libraries. If you are new to Tensorflow and Keras, you can follow these posts.

We consider that the data will fit some quadratic form (n = 2), i.e. \(y = a_0x^2 + a_1x + a_3\). Therefore, we transform the day values as follows:

Next, we build the model with one input and one output layer.

After that, we train model with 17 days’ samples and 10k epochs.

After training, we can check the fitting line (red) to the provided data.

Fitting line after training

Next, we want to predict coronavirus deaths in the next 9 days, from day 18 – 26th.

And finally, this is what we want to see but do NOT want to BELIEVE:

Conclusion

Well, it is just a simple prediction while ignoring thousands of factors. Sometimes, we can just pray and wait. Hopefully, the pandemic can be seized in the next 10 days! Cross my fingers for all 2019-nCoV patients! Below is the updated actual number of deaths for comparison:

After monitoring the data for the next few days, the model predicts quite well with some exact match, it followed the trends until the pandemic seemed to be under control.

Add comment

A.I, Data and Software Engineering

PetaMinds focuses on developing the coolest topics in data science, A.I, and programming, and make them so digestible for everyone to learn and create amazing applications in a short time.

Pin It on Pinterest

Newsletters

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Petaminds will use the information you provide on this form to be in touch with you and to provide updates.