This is the backend code for the RL algorithm used in the Oralytics clinical trial. The RL algorithm in Oralytics optimizes the delivery of engagement prompts to participants to maximize their brushing quality (or oral self-care behaviors). For more information about Oralytics, please see the following papers:
- Designing Reinforcemnt Learning Algorithms for Digital Interventions: Pre-Implementation Guidelines
- Reward Design For An Online Reinforcement Learning Algorithm Supporting Oral Self-Care
If you use our code or algorithm in anyway, please cite us:
@article{trella2022designing,
title={Designing reinforcement learning algorithms for digital interventions: pre-implementation guidelines},
author={Trella, Anna L and Zhang, Kelly W and Nahum-Shani, Inbal and Shetty, Vivek and Doshi-Velez, Finale and Murphy, Susan A},
journal={Algorithms},
volume={15},
number={8},
pages={255},
year={2022},
publisher={MDPI}
}
@inproceedings{trella2023reward,
title={Reward design for an online reinforcement learning algorithm supporting oral self-care},
author={Trella, Anna L and Zhang, Kelly W and Nahum-Shani, Inbal and Shetty, Vivek and Doshi-Velez, Finale and Murphy, Susan A},
booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
volume={37},
number={13},
pages={15724--15730},
year={2023}
}
- Make sure you have mysql installed locally (video here).
- Run
brew services start mysql
to initialize. - To check that mysql works, try:
mysql -u root
- Create two databases (one for local dev, one for unit testing). Ex:
CREATE DATABASE local;
CREATE DATABASE test_data;
- To connect to MySQL data tables, open the file and change the fields in
database/database_connector.py
:host="", user="", password="", database=""
then run database/python3 create_data_tables.py
For readibility of data tables, run python3 database/mysql_to_df.py
to turn all MySQL data tables to csv files and Pandas Dataframe pickles.
python3 -m unittest discover tests
will run all unit tests in the tests/
folder.
Flask-Mail is a package that needs to be downloaded. If you do not already have flask_mail installed, try:
pip3 install --user Flask-Mail
This flask app was built using version 2.3.2.: https://flask.palletsprojects.com/en/2.3.x/patterns/packages/.
If this is the first time running the flask app, you need to tell Flask where the application instance is:
export FLASK_APP=rl_ohrs
Then install and run the application:
pip3 install -e .
Then run either:
python3 -m flask run
or flask run
depending on your system.