Tackling COVID-19 with FB Prophet
- Arunesh Mishra
- Apr 7, 2020
- 2 min read
Crisis Response
The COVID-19 coronavirus presents an unprecedented, global challenge. As engineering students, we should ask ourselves what can we do? In this post, we'll try to understand trends in COVID-19 cases, and by the end of this post, we will be able to make predictions for future COVID-19 cases using FB Prophet.

What is Facebook Prophet?
Facebook Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. One of the reasons that I chose the Prophet was that it works very well with outliers and missing data.
Let's get started!
The first step is to import all the necessary libraries. Pandas will be used to import and group the data by dates, Seaborn & Matplotlib will be used for visualization and FB Prophet for forecasting the data. While the original data had many more columns of information, I only chose the Date, Confirmed, Deaths and Recovered columns.

In the next step, I created a separate Dataframe of Date and Confirmed cases. And then followed by grouping all the cases in a single day into one row.

As you can see in the picture above, Day 1 (22nd Jan) has 555 cases in total and Day 74 (5th April) has 1.27 million cases.
Let's visualize this data for better understanding using Seaborn Library. As you can see below that there has been exponential growth in the number of COVID-19 cases since January.

Time for some predictions:
First, create a Prophet object and fit the confirmed data frame to the object. Make sure that you rename the column names as 'ds' and 'y'. No specific reason for it, that's how Prophet works. Next step, use make_future_dataframe (period=n), we have chosen n=15 which will give us predictions for the next 15 days.

Let's graph our results using plot function.

The black dots are original cases whereas the blue shaded line is the prediction for the next 15 days. You can see that the number of cases is expected to cross 2 million by 23rd April. We can also try to see trends on cases during weeksday by using the plot_components function.

In this post, I used FB Prophet for confirmed cases. You can also try the same for Deaths and Recovered columns.
Dataset credits: Kaggle
Facebook Prophet: Getting started
Comments