Skip to content

forecasts the daily number of hospital inpatients for the next 14 days

Notifications You must be signed in to change notification settings

frizchar/number-of-inpatients-forecasting

Repository files navigation

Forecasting the Number of Hospital Inpatients

Overview

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.

Input files

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.

Input parameters

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 module run_prod_model.py
  • 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

Dependencies

The required packages are included in file requirements.txt.
Python interpreter version used for this project: 3.9.4

Code structure

Following are descriptions of the python modules used in the code:

  • main.py: defines the input parameters described above and then invokes module engine.py
  • engine.py: controls the code flow, depending on the selected values of the input parameters
  • run_test_model.py: runs prophet in test mode
  • run_prod_model.py: runs prophet in production mode
  • fetch_data.py: reads the input .xlsx files of each hospital
  • output.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;
Loading

About

forecasts the daily number of hospital inpatients for the next 14 days

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages