We are forecasting the number of daily hospital inpatients y of hospitals [hospital_1, hospital_2] for h days into the future (forecast horizon=h).
The code may be modified to process data of any number of hospitals (see 'input parameters' below).
The code is written in Python and the forecasting is implemented by using the prophet algorithm.
The code loads (n) .xlsx
files, each one containing data for each hospital.
Each .xlsx
file includes columns ds := date and y := number of daily inpatients.
For this implementation n = 2.
Here are the input parameters that are determined in module main.py
:
- RUN_MODE : determines the mode of the code and takes the following values:
-
'prod' : invokes module
run_prod_model.py
-
'test' : invokes module
run_test_model.py
-
'hybrid' : invokes module
run_test_model.py
and then modulerun_prod_model.py
-
'prod' : invokes module
- HOSPITAL_list : list holding the hospital IDs of the hospitals whose data the code processes ( values : 1, 2 )
- HORIZON_VALUE : determines the forecast horizon, namely the number of days for which the code forecasts the number of inpatients ( for our implementation we choose value HORIZON_VALUE = 14 )
- CAP_TYPE : shapes the prophet parameter cap that determines the maximum number of inpatients allowed by prophet and takes the following values:
-
'hard': in this case
$cap = max(y)$ , where$y$ are the historical data -
'soft': in this case
$cap = max(y) + round[0.08*max(y)]$ , where$y$ are the historical data
-
'hard': in this case
The required packages are included in file requirements.txt
.
Python interpreter version used for this project: 3.9.4
Following are descriptions of the python modules used in the code:
main.py
: defines the input parameters described above and then invokes moduleengine.py
engine.py
: controls the code flow, depending on the selected values of the input parametersrun_test_model.py
: runs prophet in test moderun_prod_model.py
: runs prophet in production modefetch_data.py
: reads the input.xlsx
files of each hospitaloutput.py
: stores results in relative folder path'./data_pool/'
Below is the code diagram displaying the relationships between its modules:
graph LR;
main-->engine;
engine-->run_test_model;
engine-->run_prod_model;
engine-->output;
run_test_model-->fetch_data;
run_prod_model-->fetch_data;