DEV Community

Oshi Gupta
Oshi Gupta

Posted on

MLOps with CML

My Workflow

Managing machine learning model is a tedious job and specially when dealing with large datasets.To automate a machine learning model like to train it,evaluate it can be done by using CML(Continuous Machine Learning) as a part of MLOps(Machine Learning Operations) which is a CI/CD tool for Machine Learning projects.

In the following workflow a tensorflow regression model is trained with CML and along with it's model performance which is also recorded and will be generated on a PUSH GitHub event.

name: mlops-tensorflow-regression
on: [push]
jobs:
  run:
    runs-on: [ubuntu-latest]
    container: docker://dvcorg/cml-py3:latest
    steps:
      - uses: actions/checkout@v2
      - name: 'Train the model'
        env:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
        run: |
          # Your ML workflow goes here
          pip install -r requirements.txt
          python model.py

          echo "## Model Metrics" > report.md
          cat metrics.txt >> report.md

          echo "\n## Model Performance" >> report.md
          echo "Model performance metrics are on the plot below." >> report.md

          cml-publish model_results.png --md >> report.md

          cml-send-comment report.md
Enter fullscreen mode Exit fullscreen mode

This model metrics will be sent with an email and also on pushing the code from GitHub bot.

This is what model performance looks like when you push the code and run the above workflow.

  • The first image is of getting reply after pushing the code
    Model Performance after code commit

  • The second image is about getting results on an email
    Model Performance as an email

    Submission Category:

This workflow falls in the category of DIY Deployments

Yaml File or Link to Code

GitHub logo oshi36 / ml-ops-cml

To automate a machine learning model with the help of CML (Continuous Machine Learning) with GitHub Actions.

ML-Ops-CML

To automate a machine learning model with the help of CML (Continuous Machine Learning) with GitHub Actions.

For this a Tensorflow Regression model is created in model.py and python libraries requirements in requirements.txt.

A GitHub Action with CML is made inside .github/workflows/ which will train the model and find out the metrics and plot a graph on it.

This GitHub Action will work on PUSH events and will train the model as you do commit
After the training model performance wil be send as a reply to the commit and to the registered GitHub Email as well as shown in the image below

Model Performance details as a comment

Model Performance details in an Email

Thank You for reading this as this was my first Github Actions and I really enjoyed and learnt new while building this and a huge thank you to the Dev community and GitHub organization for organising this Github Actions hackathon.

Top comments (0)