Content from this website is STRICTLY ONLY for educational and research purposes and may contain errors. The model and data are inaccurate to the complex, evolving, and heterogeneous realities of different countries. Predictions are uncertain by nature. Readers must take any predictions with caution. Over-optimism based on some predicted end dates is dangerous because it may loosen our disciplines and controls and cause the turnaround of the virus and infection, and must be avoided.
I created this project in the earlier April 2020, it's a Python CLI terminal application that predicting COVID-19
active cases based on raw dataset scraped from the
I also made a website to showcase these charts including both linear and logarithmic.
My Github repository page.
Let's clone a repository at Github,
$ git clone https://github.com/loouislow81/covid19-trend-predictor.git $ cd covid19-trend-predictor
Without make dirty of your host system, we use the
Python virtual environment to encapsulate the project files and ton of necessary dependency modules that we will need to install in order for this application to run properly.
$ virtualenv -p python3 venv $ source venv/bin/activate $ (venv) pip install -r requirements.txt --default-timeout=1000
Before anything else, you will need to add the country name that you want in the
configure.py file, like in the example below,
... countries = [ "China", "Hong Kong", "Indonesia", "Japan", "Malaysia", "Philippines", "Singapore", "S. Korea", "Taiwan", "Thailand" ] ...
And then, we will proceed next to generate a new dataset with the following commands. You choose which one to go generate, one by one.
The generated raw dataset is located in the
./raw_dataset directory with separated
# generate `cases` datasets $ (venv) scrapy runspider --nolog cases_dataset.py -o raw_dataset/countries.csv -t csv # generate `deaths` datasets $ (venv) scrapy runspider --nolog deaths_dataset.py -o raw_dataset/countries.csv -t csv # generate `infected` (active cases) datasets $ (venv) scrapy runspider --nolog infected_dataset.py -o raw_dataset/countries.csv -t csv
predict_model.py with examples below to generate the prediction charts either in linear or logarithmic versions.
# usage # <model_name> is either `cases`, `deaths` or `infected` $ predict_model.py -h [-m|--model] <model_name> [-c|--chart] <linear|logarithm> [-d|--day] <day> # examples # without args, the default is set to cases model, linear chart and 90 days $ (venv) python predict_model.py --model cases --chart linear --day 60 $ (venv) python predict_model.py -m cases -c linear -d 60
The generated prediction charts are located in the
./results/ directory with separated directories, such as
The website URL to showcase the charts https://covid19-90days-prediction-charts.netlify.app.
Run these commands below to compile and serve the website to run locally on your system.
# move generated charts into `./web/assets/image/` directory. $ (venv) bash move_to_web.sh # set up Krugurt.js frontend project $ (venv) cd web $ (venv)(web) npm install $ (venv)(web) npm run build-prod $ (venv)(web) npm run serve
Thank you for reading this article. Please
unicornwould encourage me to write more about this kind of article next time.