This project uses Docker and Kubernetes to operationalize a Machine Learning Microservice API, a Flask app that serves out predictions (inference) about housing prices through API calls.
A pre-trained sklearn
model is given to predict housing prices in Boston according to several features, such as average rooms in a home and data about highway access, teacher-to-pupil ratios, and so on. The data is taken from Kaggle.
This project could be extended to any pre-trained machine learning model, such as those for image recognition and data labeling.
- Run
make setup
to create a virtual env - Run
source venv/bin/activate
to activate the virtual env - Run
make install
to install the necessary dependencies
- Standalone:
python app.py
- Run in Docker:
./run_docker.sh
- Run in Kubernetes:
./run_kubernetes.sh
- Run a simple test:
./make_prediction.sh
model_data/
- stores the pre-trained model for prediction.
output_txt_files/
- stores some example outputs after running
run_docker.sh
andrun_kubernetes.sh
.
- stores some example outputs after running
app.py
- A Flask app that processes and passes input data through the prediction model, and responds with the resultant prediction.
run_docker.sh
- This script builds the Docker image for the app, and runs the containerized app locally.
upload_docker.sh
- This script tags and uploads the Docker image to Docker Hub.
run_kubernetes.sh
- This script pulls the Docker image from Docker Hub, and deploys it to the local kubernetes cluster.
make_prediction.sh
- This script sends some input data to our app's prediction API, and outputs the response. Run this script to test if the app is running properly.