Skip to content

manuelgilm/mlflow_for_ml_dev

Repository files navigation

MLflow for Machine Learning Development

This repository is part of the playlist on Youtube named: MLflow for Machine Learning Development (new)

Notebooks

A series of notebooks is provided to follow along the playlist, there are two folders with notebooks that addresses two main topics.

Experiment Tracking Fundamentals

The fundamentals of experiment tracking and machine learning development with MLflow are explored in the notebooks under this topic. It addresses the concepts of Experiment and Run, and the metadata involved during ML model development, such as metrics, artifacts, parameters, and tags. Additionally, it covers tracking ML models using MLflow flavors, including how to provide signatures, input examples, and other metadata with the model.

Custom model creation is also addressed in this section, demonstrating how to use the Pyfunc Flavor to define your custom model using a Python function or Python class. Finally, it covers concepts associated with the Model Registry, including Model objects, Model versions, aliases, and Model Registry operations.

Traditional ML Model Evaluation.

This section focuses on evaluating traditional machine learning models using the mlflow.evaluate method. It provides an overview of model evaluation fundamentals, including how to assess model performance. Additionally, it demonstrates how to define custom metrics to tailor evaluations to specific use cases and create custom artifacts to enhance the evaluation process. These concepts are essential for gaining deeper insights into model behavior and improving the overall quality of machine learning workflows.

Package: mlflow_for_ml_dev

To run the notebooks is important to create the virtual environment with the required libraries, such a jupyter an the respective kernel. In addition, you need packages such as sklearn, mlflow and pandas

How to use with Poetry.

  • Installing poetry

To install poetry follow the steps provided in the Poetry Documentation.

  • Creating the virtual environment.

After installing Poetry, to create the virtual environment (.venv) you can run:

poetry install

  • Activate the virtual environment.

    • With poetry:

      poetry shell

    • Without Poetry:

      Depending on the terminal you are using:

      • Command Prompt (cmd):

        .venv\Scripts\activate

      • Git Bash

        source .venv/Scripts/activate

How to use without Poetry.

  • Create Virtual Environment.

    python -m venv .venv

  • Activate the environment

    Depending on the terminal you are using:

    • Command Prompt (cmd):

      .venv\Scripts\activate

    • Git Bash

      source .venv/Scripts/activate

  • Install requirements.

    pip install -r requirements.txt

Note: If you are not using Poetry to manage the project and instead created a virtual environment, the functions defined in the entry point modules cannot be executed directly through the command line. To address this, you need to refactor the code to allow execution of specific functions within the Python script. For example:

def train_multi_model():
    # Your training logic here
    ...

if __name__ == "__main__":
    train_multi_model()

Then, run the script with the desired function as an argument:

(.venv) python path/to/script.py train_multi_model

Content:

Experiment Tracking with MLflow:

Local Model Serving Use cases.

In this section, we explore how MLflow enables local model serving. You'll learn how to launch a local MLflow server to deploy and serve ML models, making them accessible for real-time predictions via REST API endpoints. This approach is useful for testing, prototyping, and integrating models into local applications before moving to production environments.

Usecases

  • Iris classifier

  • Digit Recognition

  • Walmart Sales Regression

  • Diabetes Prediction

Contributing

If you want to contribute to this project and make it better, your help is very welcome. Contributing is also a great way to learn more and improve your skills. You can contribute in different ways:

  • Reporting a bug
  • Coming up with a feature request
  • Writing code
  • Writing tests
  • Writing documentation
  • Reviewing code
  • Giving feedback on the project
  • Spreading the word
  • Sharing the project

Contact

If you need to contact me, you can reach me at:

About

Repository with code examples of mlflow

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published