Building and deploying a regression ML model.
This code is used in this blog post.
Python 3
The Makefile included with this project contains targets that help to automate several tasks.
To download the source code execute this command:
git clone https://github.com/schmidtbri/regression-modelThen create a virtual environment and activate it:
# go into the project directory
cd regression-model
make venv
source venv/bin/activateInstall the dependencies:
make dependenciesThe requirements.txt file only includes the dependencies needed to make predictions with the model. To train the model you'll need to install the dependencies from the train_requirements.txt file:
make train-dependenciesTo run the unit test suite execute these commands:
# first install the test dependencies
make test-dependencies
# run the test suite
make test
# clean up the unit tests
make clean-testTo start the service locally, execute these commands:
uvicorn rest_model_service.main:app --reloadTo generate the OpenAPI spec file for the REST service that hosts the model, execute these commands:
export PYTHONPATH=./
generate_openapi --output_file=service_contract.yamlTo build a docker image for the service, run this command:
docker build -t insurance_charges_model:0.1.0 .To run the image, execute this command:
docker run -d -p 80:80 insurance_charges_model:0.1.0To watch the logs coming from the image, execute this command:
docker logs $(docker ps -lq)To stop the docker image, execute this command:
docker kill $(docker ps -lq)