I was inspired by this excellent Medium article by Fortunato Nucera on the subject of using Metropolis Hastings for Bayesian Regression and set about trying to implement a variation of this myself. Additionally, I thought it would make for an interesting challenge to animate the results in streamlit!
In this project I wanted to:
- implement the Metropolis Hastings algorithm for a Simple Linear Regression model.
- create a streamlit app.
- test and deploy this application.
TODOS:
- ✨Style✨ the main page.
- Make parameters such as the number of burn in samples configurable in the side bar.
- Extend this to Bayesian Multiple Linear Regression.
- Deploy this on a Kubernetes instance (e.g. Minikube).
# Setup for development
pip install pipenv
pipenv shell
pipenv install --devpipenv shell
streamlit run main.pyIf you want to generate new data, run the following command:
python scripts/generate_data.pyThis package uses Tox to manage testing across multiple environments - see the tox.ini file. Testing of the MCMC logic uses pytest and hypothesis.
# Example tox commands
tox # run all
tox -e py310 # test in python 3.10
tox -e lint
# Run tests alone
pytest