Coronavirus: Facebook Prophet & Time Series Analysis Predictions April 2020

Andre Williams
Analytics Vidhya
Published in
4 min readApr 1, 2020
source:https://dph.georgia.gov/novelcoronavirus

The coronavirus is spreading very quickly but too quickly to predict future cases, recoveries, and deaths. In this article, I share some techniques on how to apply time series analysis using Facebook prophet and I apply visualizations of the coronavirus epidemic in real-time. This analysis is solely for educational purposes and has no other intent but to show insights on how you can apply these machine learning libraries and algorithms to real-world situations. The data provided will be in Jupyter Notebook Format.

This analysis is solely for educational purposes and has no other intent but to show insights on how you can apply these machine learning libraries and algorithms to the real-world phenomenons.

source: https://www.grammarly.com/blog/how-to-measure-goals/

GOALS

The goal of this project is to help shine light on what’s actually happening in the world with the coronavirus without all the media. There is a lot of research and data around COVID-19. This analysis is designed to help provide useful insights with updated data.

  • Grab Updated Data on COVID-19
  • Apply Support Vector Machine Learning Model
  • Apply Polynomial Regression Machine Learning Model
  • Apply Time Series Analysis
  • Analyze Confirmed, Deaths, and Recovered Cases
  • Visualize the data in graphs and charts
  • Draw Conclusions From Data
source: My Code

Data Source

source: https://github.com/CSSEGISandData/COVID-19

source: https://media.tenor.com/images/edee3f2b307be864038318eafbc7d5ad/tenor.png

Side Note

But before we start, there are some basic things to take note of.

Less Data: Since the data available now is not that much our prediction may not be that accurate.

Presence of Effective Treatment or Vaccine or Medication: In the case of availability of an effective treatment or medication, the result of the outbreak will drastically decline which can affect our prediction.

This Analysis is Completely for Educational Purposes

Code for Facebook Prophet Forecasting Analysis

Workflow (Game-plan)

  • Fetch and Prepare Data
  • Group our Data by Dates
  • Rename our Column specifically as ds and y for FB Prophet
  • Split our Dataset into Train and Test
  • Build our model and make a prediction
  • Plot predictions

Highlights From Code

All The Code is Below:

This Analysis is Completely for Educational Purposes

Code for Polynomial Regression, Support Vector Machine and Visualizations

This Analysis is Completely for Educational Purposes

More Highlights From Code:

source:https://store.steampowered.com/app/497350/Conclusion/

Conclusion

Facebook Prophet

To conclude, we can see some similarities in our prediction and our test data plots with Facebook Prophet and time-series analysis. We can also use the add_changepoints_to_plot function to check the points in which there were changes in the trend.

Support Vector Machine & Polynomial Regression

It looks like our test data fitted the data well for both models but still needs more work and tuning for optimal accuracy. I could tweak the training and testing splitting with cross validation to get better results. However, more data would be ideal to make a bigger difference on the model.

Overall

Based on our prediction and our plot for the test dataset we can see some similarities in our plot. It looks like our model is on track as it shows an increase in the number of confirmed cases — a rising trend just like our test data set shows.

I hope this analysis helped and inspires you to look beyond the media and do your own analysis with credible data sources. Stay safe out there!

More About Me

--

--

Andre Williams
Analytics Vidhya

Andre is a data scientist in the Bay Area who loves sharing content and making the complex simple.