This repository hosts a machine learning model deployed as a RESTful API using FastAPI. It leverages a RandomForestClassifier model trained on NY building data, offering an endpoint for making predictions.
.fastapi-model-deploy
- train_app
- retrain.py - training/re-training
- README.md - Pre-processing findings
- infra_app
- app.py - Flask API file
- incomemodel.py - pydantic for input validation
- Dockerfile - serving container
- download_latest_model.py - Download latest model from mlflow
- requirements.txt
- README.md - Production style pipeline
- data
- train - training data
- test - testing data
- notebooks -- Data analysis/preprocessing
- models -- save trained model to this dir
- README.md
- Instructions for setting up and running the repo locally
- python 3.9+
- pip
- docker
- Clone the repo
- Create a virtual env
- Install the dependencies for model training in train_app
- pip install -r requirements.txt
- run 'retrain.py' --> 'python retrain.py'
- mlflow will be up and running locally and the new model that we currently trained will be register
- navigate to the Mlflow url to check out
- You will see the model saved in models directory
- Now move to infra_app directory
- run 'download_latest_model.py'
- this will connect to mlflow get the latest model and saves in the pwd
- Run Dockerfile to build the image
- 'docker build -t flask-api .'
- 'docker run -p 8000:8080 flask-api'
- Test the api
- connect to api docs and test --> http://localhost:8000/docs