skytells-research / nCOVID-19-Spread-Prediction

Coronavirus Spread Prediction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Coronavirus Spread Prediction

Python script, based on SIR model + astroABC library + Wikipedia data, to predict coronavirus spread.

Implementation details

Simple, one-dimensional SIR model has been used to simulate the number of people affected. It consists of three dynamic variables, each as a function of time:

  • S(t) - percentage of susceptible people (those who can become infected), initially equal 1
  • I(t) - percentage of infected people
  • R(t) - percentage of people who are no longer infected (so dead or recovered), initially equal 0

and two parameters:

  • b - transition rate between S and I
  • k - transition rate between I and R

Cost function which calculates the difference between real data and the data generated by model is max-squared-error. It takes cumulative number of cases as well as temporary number of cases as an input.

To minimize the cost function, the Approximate Bayesian Computation Sequential Monte Carlo (ABC SMC) algorithm implementation of astroABC has been introduced with four parameters:

Parameter Description Distribution Hiperparameters
s% percentage of initially susceptible people in whole population gamma k=0.5, scale=0.01
i% percentage of initially infected people uniform from=0, to=0.1
b transition rate between S and I from SIR model uniform from=0.1, to=1
k transition rate between I and R from SIR model uniform from=0, to=0.1

Other ABC SMC properties:

  • particles: 20
  • iterations: 10
  • transitions: from 1e-8 to 1e-13 exponentially

Other values in the script to adjust:

  • max_offset - number of real data initial days which can be omitted by cost function (initial data does not usually fit the model)
  • days_to_verify - number of real data final days omitted by cost function (in order to verify predictions)
  • days_to_predict - number of days predicted

Install & Run

Astroabc

$ pip install astroabc==1.5.0

Dependencies

  • numpy
  • scipy
  • mpi4py
  • multiprocessing
  • sklearn

Python distributions like Anaconda have most of what is needed. You can then conda install or pip install all of the required dependencies.

$ conda install  numpy scipy scikit-learn mpi4py
$ pip install numpy scipy scikit-learn mpi4py

Run

pip install numpy scipy matplotlib
git clone https://github.com/skytells-research/coronavirus-spread-prediction
cd nCOVID-19-Spread-Prediction
python predict.py

Examples

  • Chinese data till 22.03.2020 predicted using data till 21.02.2020

obraz

MIT License

Copyright (c) 2020 Skytells AI Research

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Coronavirus Spread Prediction

License:MIT License


Languages

Language:Python 100.0%