NHS AI Lab Skunkworks project: Long Stayer Risk Stratification

Overview

Banner

NHS AI Lab Skunkworks project: Long Stayer Risk Stratification

A pilot project for the NHS AI Lab Skunkworks team, Long Stayer Risk Stratification uses historical data from Gloucestershire Hospitals NHS Foundation Trust to predict how long a patient will stay in hospital upon admission.

As the successful candidate from a Dragons’ Den-style project pitch, Long Stayer Risk Stratification was first picked as a pilot project for the AI (Artificial Intelligence) Skunkworks team in April 2021.

Background

Hospital long stayers, those with a length of stay (LoS) of 21 days or longer, have significantly worse medical and social outcomes than other patients. Long-stayers are often medically optimised (fit for discharge) many days before their actual discharge. Moreover, there are a complex mixture of medical, cultural and socioeconomic factors which contribute to the causes of unnecessary long stays.

This repository contains a proof-of-concept demonstrator, developed as part of a research project - a collaboration between Polygeist, Gloucestershire Hospitals NHS Foundation Trust, NHSX, and the Home Office’s Accelerated Capability Environment (ACE). The project aimed to achieve two core objectives:
firstly, to determine if an experimental artificial intelligence (AI) approach to predicting hospital long-stayers was possible; secondly, if so, to produce a proof-of-concept (PoC) risk stratification tool.

Stratification Tool

Banner

The tool displays the LTSS for a patient record, between Level 1 and 5; with 5 being the most severe risk of the patient becoming a long stayer. The tool allows exploration of various factors, and enables the user to edit those entries to produce refined or hypothetical estimates of the patient's risk.

The tool has shown good risk stratification for real data, with Level 1 consisted of 99% short stayers, and minor cases, with less than 1% of long-stayers being classified as very low risk. Moreover, 66% of all long-stayers were classified as Risk Category 4 and 5, with proportions steadily increasing through the categories. Risk Category 5 also stratified those patients with long and serious hospital stays under the long-stay threshold (serious and lengthy stays).

Documentation:

Docs Description
REST API API Endpoint descriptions and usage examples
LTSS Flask App API Package documentation for the ltss Python package and incorporated submodules
Deployment Instructions Build and run instruction for development or production deployments
WebUI Overview Description of UI components and application structure
Configuration Files Overview of provided configuration files
Production Build Configuration Files Overview of the configuration files provided for production build Docker containers
Training Description of the training process for the models used in the LTSS API

NHS AI Lab Skunkworks

The project is supported by the NHS AI Lab Skunkworks, which exists within the NHS AI Lab to support the health and care community to rapidly progress ideas from the conceptual stage to a proof of concept.

Find out more about the NHS AI Lab Skunkworks. Join our Virtual Hub to hear more about future crowdsourcing event opportunities. Get in touch with the Skunkworks team at [email protected].

Comments
  • No such file or directory: 'config/los_model.state'

    No such file or directory: 'config/los_model.state'

    In local deployment of development server. $ FLASK_APP=ltss:create_app FLASK_ENV=development FLASK_DEBUG=1 python3 -m flask run --host=0.0.0.0 fails with

    • Serving Flask app 'ltss:create_app' (lazy loading)
    • Environment: development
    • Debug mode: on Traceback (most recent call last): File "/home/brian/anaconda3/envs/beds/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/brian/anaconda3/envs/beds/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/main.py", line 3, in main() File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 990, in main cli.main(args=sys.argv[1:]) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 596, in main return super().main(*args, **kwargs) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/click/decorators.py", line 84, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 845, in run_command app = DispatchingApp(info.load_app, use_eager_loading=eager_loading) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 321, in init self._load_unlocked() File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 346, in _load_unlocked self._app = rv = self.loader() File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 402, in load_app app = locate_app(self, import_name, name) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 275, in locate_app return find_app_by_string(script_info, module, app_name) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 201, in find_app_by_string app = call_factory(script_info, attr, args, kwargs) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/flask/cli.py", line 119, in call_factory return app_factory(*args, **kwargs) File "/home/brian/Beds/skunkworks-long-stayer-risk-stratification/ltss/init.py", line 47, in create_app initialise_models() File "/home/brian/Beds/skunkworks-long-stayer-risk-stratification/ltss/init.py", line 36, in initialise_models LOS_MODEL = los_model.init_model() File "/home/brian/Beds/skunkworks-long-stayer-risk-stratification/ltss/los_model.py", line 95, in init_model predictor.load_state_dict(torch.load(model_file, map_location=torch.device('cpu'))) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/torch/serialization.py", line 579, in load with _open_file_like(f, 'rb') as opened_file: File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "/home/brian/anaconda3/envs/beds/lib/python3.8/site-packages/torch/serialization.py", line 211, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'config/los_model.state'
    opened by BrianBut 1
  • Bump numpy from 1.20.3 to 1.22.0

    Bump numpy from 1.20.3 to 1.22.0

    Bumps numpy from 1.20.3 to 1.22.0.

    Release notes

    Sourced from numpy's releases.

    v1.22.0

    NumPy 1.22.0 Release Notes

    NumPy 1.22.0 is a big release featuring the work of 153 contributors spread over 609 pull requests. There have been many improvements, highlights are:

    • Annotations of the main namespace are essentially complete. Upstream is a moving target, so there will likely be further improvements, but the major work is done. This is probably the most user visible enhancement in this release.
    • A preliminary version of the proposed Array-API is provided. This is a step in creating a standard collection of functions that can be used across application such as CuPy and JAX.
    • NumPy now has a DLPack backend. DLPack provides a common interchange format for array (tensor) data.
    • New methods for quantile, percentile, and related functions. The new methods provide a complete set of the methods commonly found in the literature.
    • A new configurable allocator for use by downstream projects.

    These are in addition to the ongoing work to provide SIMD support for commonly used functions, improvements to F2PY, and better documentation.

    The Python versions supported in this release are 3.8-3.10, Python 3.7 has been dropped. Note that 32 bit wheels are only provided for Python 3.8 and 3.9 on Windows, all other wheels are 64 bits on account of Ubuntu, Fedora, and other Linux distributions dropping 32 bit support. All 64 bit wheels are also linked with 64 bit integer OpenBLAS, which should fix the occasional problems encountered by folks using truly huge arrays.

    Expired deprecations

    Deprecated numeric style dtype strings have been removed

    Using the strings "Bytes0", "Datetime64", "Str0", "Uint32", and "Uint64" as a dtype will now raise a TypeError.

    (gh-19539)

    Expired deprecations for loads, ndfromtxt, and mafromtxt in npyio

    numpy.loads was deprecated in v1.15, with the recommendation that users use pickle.loads instead. ndfromtxt and mafromtxt were both deprecated in v1.17 - users should use numpy.genfromtxt instead with the appropriate value for the usemask parameter.

    (gh-19615)

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Add links for fake data generation and training

    Add links for fake data generation and training

    This PR includes links for generating fake data and training the required models in the deployment instructions, to help with future issues such as #11.

    What to review: updated documentation

    opened by amadeuspzs 0
  • Visual overview

    Visual overview

    This PR resolves #4 and adds a visual, high-level, overview of the training and deployment processes.

    The technical report states that the MAX of {NN,CDF} models is used, but the UI component seems to display the NN value so this needs further exploring: https://github.com/nhsx/skunkworks-long-stayer-risk-stratification/blob/90c524a9bcc9736c0f75682b2fb8218573853782/ltss/risk_model.py#L287

    question 
    opened by amadeuspzs 0
  • Fake Data Generator

    Fake Data Generator

    Generating fake data

    Overview and Purpose

    The purpose of generate_fake_data.py is to create a .csv file with fake data with the following intended applications:

    • An example of how data needs to be formatted to be passed into the model
    • To ensure the files are being generated correctly to test GUI setup.
    • To test the setup and running of the repo

    The purpose of the fake data is NOT too:

    • DO NOT use the model artifacts (.pickle and .state files) generated from the fake data to make predictions which will be used in any real world application.
    • DO NOT use the fake data generated to inform any insights to be applied to a real world setting.
    • DO NOT use to test the performance of the model

    The data is generated completely randomly, with each field having random values generated independently of other fields. This generator was created having never been exposed to the real data.

    opened by Jen-Hall 0
Owner
NHSX
NHSX
Tilted Empirical Risk Minimization (ICLR '21)

Tilted Empirical Risk Minimization This repository contains the implementation for the paper Tilted Empirical Risk Minimization ICLR 2021 Empirical ri

Tian Li 40 Nov 28, 2022
A PyTorch implementation of the paper Mixup: Beyond Empirical Risk Minimization in PyTorch

Mixup: Beyond Empirical Risk Minimization in PyTorch This is an unofficial PyTorch implementation of mixup: Beyond Empirical Risk Minimization. The co

Harry Yang 121 Dec 17, 2022
A lightweight Python-based 3D network multi-agent simulator. Uses a cell-based congestion model. Calculates risk, loudness and battery capacities of the agents. Suitable for 3D network optimization tasks.

AMAZ3DSim AMAZ3DSim is a lightweight python-based 3D network multi-agent simulator. It uses a cell-based congestion model. It calculates risk, battery

Daniel Hirsch 13 Nov 4, 2022
Collision risk estimation using stochastic motion models

collision_risk_estimation Collision risk estimation using stochastic motion models. This is a new approach, based on stochastic models, to predict the

Unmesh 7 Jun 26, 2022
A Game-Theoretic Perspective on Risk-Sensitive Reinforcement Learning

Officile code repository for "A Game-Theoretic Perspective on Risk-Sensitive Reinforcement Learning"

Mathieu Godbout 1 Nov 19, 2021
Pynomial - a lightweight python library for implementing the many confidence intervals for the risk parameter of a binomial model

Pynomial - a lightweight python library for implementing the many confidence intervals for the risk parameter of a binomial model

Demetri Pananos 9 Oct 4, 2022
All-in-one Docker container that allows a user to explore Nautobot in a lab environment.

Nautobot Lab This container is not for production use! Nautobot Lab is an all-in-one Docker container that allows a user to quickly get an instance of

Nautobot 29 Sep 16, 2022
A trusty face recognition research platform developed by Tencent Youtu Lab

Introduction TFace: A trusty face recognition research platform developed by Tencent Youtu Lab. It provides a high-performance distributed training fr

Tencent 956 Jan 1, 2023
Code for the AI lab course 2021/2022 of the University of Verona

AI-Lab Code for the AI lab course 2021/2022 of the University of Verona Set-Up the environment for the curse Download Anaconda for your System. Instal

Davide Corsi 5 Oct 19, 2022
piSTAR Lab is a modular platform built to make AI experimentation accessible and fun. (pistar.ai)

piSTAR Lab WARNING: This is an early release. Overview piSTAR Lab is a modular deep reinforcement learning platform built to make AI experimentation a

piSTAR Lab 0 Aug 1, 2022
Train neural network for semantic segmentation (deep lab V3) with pytorch in less then 50 lines of code

Train neural network for semantic segmentation (deep lab V3) with pytorch in 50 lines of code Train net semantic segmentation net using Trans10K datas

null 17 Dec 19, 2022
Manipulation OpenAI Gym environments to simulate robots at the STARS lab

Manipulator Learning This repository contains a set of manipulation environments that are compatible with OpenAI Gym and simulated in pybullet. In par

STARS Laboratory 5 Dec 8, 2022
All the code and files related to the MI-Lab of UE19CS305 course in sem 5

Machine-Intelligence-Lab-CS305 The compilation of all the code an drelated files from MI-Lab UE19CS305 (of batch 2019-2023) offered by PES University

Arvind Krishna 3 Nov 10, 2022
Experiments for Operating Systems Lab (ETCS-352)

Operating Systems Lab (ETCS-352) Experiments for Operating Systems Lab (ETCS-352) performed by me in 2021 at uni. All codes are written by me except t

Deekshant Wadhwa 0 Sep 6, 2022
SAS output to EXCEL converter for Cornell/MIT Language and acquisition lab

CORNELLSASLAB SAS output to EXCEL converter for Cornell/MIT Language and acquisition lab Instructions: This python code can be used to convert SAS out

null 2 Jan 26, 2022
RITA is a family of autoregressive protein models, developed by LightOn in collaboration with the OATML group at Oxford and the Debora Marks Lab at Harvard.

RITA: a Study on Scaling Up Generative Protein Sequence Models RITA is a family of autoregressive protein models, developed by a collaboration of Ligh

LightOn 69 Dec 22, 2022
OpenLT: An open-source project for long-tail classification

OpenLT: An open-source project for long-tail classification Supported Methods for Long-tailed Recognition: Cross-Entropy Loss Focal Loss (ICCV'17) Cla

Ming Li 37 Sep 15, 2022
On Generating Extended Summaries of Long Documents

ExtendedSumm This repository contains the implementation details and datasets used in On Generating Extended Summaries of Long Documents paper at the

Georgetown Information Retrieval Lab 76 Sep 5, 2022
Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting

Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecasting This is the origin Pytorch implementation of Informer in the followin

Haoyi 3.1k Dec 29, 2022