Giter VIP home page Giter VIP logo

vineetkt / ml_fastapi_on_heroku_ci-cd Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 5.03 MB

Deploying a Machine Learning Model on Heroku with FastAPI using CI/CD tools as GitHub Actions and Heroku Automatic Deployment.

License: Other

Python 24.24% Jupyter Notebook 75.76%
machine-learning python heroku heroku-deployment github-actions fastapi ci-cd continuous-integration continuous-deployment continuous-delivery

ml_fastapi_on_heroku_ci-cd's Introduction

Overview

Deploying a Machine Learning Model on Heroku with FastAPI

Training a Random Forest classification model to predict the income category of a person based on other personal informations.

  1. Created unit tests to monitor the model performance on various slices of the data.
  2. Then, deployed the model using the FastAPI package and create API tests.
  3. Both the slice-validation and the API tests were incorporated into a CI/CD framework using GitHub Actions.
  4. UCI census datasets was used to experience updating the dataset and model in git and DVC.

Repositories

Link to the project repo

Data

The training data is the census data available at the UCI library. It is the adult.income data from the data folder.
Link: UCI Census Data

This data versioning is tracked through DVC using AWS S3 bucket as remote storage.

Model

A basic Random Forest classifier imported from scikit-learn library and fit onto the census data Model parameters are(other than default): { "random_state": 8, "max_depth": 16, "n_estimators":128 }

Refer to the - model card

The model versioning was tracked using dvc.
Also, the performance of the model was evaluated on a slice of data (code). The results are stored in the slice_output.txt for slices done on education and race.

To run the model trainer, evaluation code (link):

python main.py

Github action

Continuous integration was incorporated in the project using the Github actions. The action was completed only if the pytest and flake8 linter tests passed on the project without any error.

Unit tests

Unit tests were written for the model training and the inference API features. The tests are done using the pytest library via command:

pytest test/ -vv

API Creation

A FastAPI framework was developed for the inference API using the input type-hints example from pydantic library The API main file is the inference_api.py

API Deployment

The API was deployed on Heroku using the main branch of the current GitHub repository with Continuous Delivery enabled.

ml_fastapi_on_heroku_ci-cd's People

Contributors

vineetkt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tmattel rfajri27

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.