Data Analysis of COVID-19 outbreak using matplotlib and fbprophet

The purpose of this blog post is to perform a data analysis of the COVID-19 outbreak, arrive at some charts and perform some forecasting for the near future.

Install Python and Jupyter Notebook to Windows 10 (64 bit)

  1. Download Python 3.7.4 or latest from “https://www.python.org/downloads/release/python-374/” url
  2. Choose and select “x86–64 executable installer” for Windows 10–64 bit computer and install
  3. Check the installation by running “Idle”
  4. Set “Python37” path and “Python37/Scripts” path to environment variable
  5. Open command prompt and check the python version using “python –version”
  6. Install pip using “pip install virtualenv”
  7. Upgrade pip using “python -m pip install -upgrade pip”
  8. Create a virtual environment called opencv (“virtualenv opencv”)
  9. Move to Scripts folder and activate opencv virtual environment using “activate.bat”
  10. Install numpy using “pip install numpy”
  11. Install OpenCV using “pip install opencv-python”
  12. Install Matplotlib using “pip install matplotlib”
  13. Install Jupyter using “python -m pip install jupyter”
  14. Run Jupyter Notebook using “jupyter notebook”
  15. Start the notebook server and popup dashboard in browser using “localhost:8888/tree” url
  16. Create your first notebook using dashboard by clicking on new Python 3

17. Type print (“Hello World”) in the cell and click Run to view the output or Type 3 + 5 in the cell and view output.

Reference :

https://medium.com/@kswalawage/install-python-and-jupyter-notebook-to-windows-10-64-bit-66db782e1d02

Plot a graph of existing data

  1. Install conda using miniconda https://docs.conda.io/projects/conda/en/latest/user-guide/install/. Advisable to reboot the laptop post installation.
  2. Open conda powershell prompt

cd covid-19-notebooks

conda env create -f environment.yaml

  • (base) PS C:\MainFolder\CondaInstalledFolder> conda activate COVID19
  • (COVID19) PS C:\MainFolder\CondaInstalledFolder> cd D:\covid-19\covid-19-notebooks\notebooks

(COVID19) PS D:\covid-19\covid-19-notebooks\notebooks> jupyter notebook

  • Ensure that the attached csv (data) file and the notebook file are present in the folder. Have modified the code to update the graph. You can customize it the way you like.
  • The output can be viewed like in the attached screen below.

Reference : https://github.com/alexamici/covid-19-notebooks

Plot a graph for forecasted data

  1. Download the corona virus dataset from https://www.kaggle.com/chriscc/coronavirus-confirmed-prediction-with-prophet
  1. Create a new environment with Python3.5
    1. conda create -n pht python=3.5 anaconda
  2. Install Prophet using the command.
    1. conda install -c conda-forge fbprophet
  3. (base) PS C:\MainFolder\CondaInstalledFolder> conda activate pht
  4. (pht) PS C:\MainFolder\CondaInstalledFolder> cd D:\covid-19\covid-19-notebooks\notebooks
  5. (pht) PS D:\covid-19\covid-19-notebooks\notebooks> jupyter notebook
  6. Run the cells in the attached notebook along with the attached data.

8. The output can be viewed like in the attached screen below. It is prediction of cases over the next 1 month.

(The specific graph below is the prediction of number of cases for Canada till May-09-2020.)

Reference :

https://stackoverflow.com/questions/42822902/can-someone-help-me-in-installing-python-package-prophet-on-windows-10

https://www.worldometers.info/coronavirus/

The Notebook

Run

$ jupyter nbconvert --to html mynotebook.ipynb

to convert the notebook to html or pdf.

xelatex will need to be installed for converting to pdf.

Concluding Statement

It goes without saying that

Your analytics and Insights are only as good as the data that feeds them !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: