This repository is part of the playlist on Youtube named: MLflow for Machine Learning Development (new)
A series of notebooks is provided to follow along the playlist, there are two folders with notebooks that addresses two main topics.
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.
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.
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
- 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
-
-
-
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
-
mlflow_for_ml_dev
package- notebooks
-
experiment Tracking Fundamentals.
-
Starting with MLflow Experiments. Notebook: 1_1_experiments_create_experiments:
-
Retrieve Experiments. Notebook: 1_2_experiments_retrieve_experiment.
-
Updating Experiments. Notebook:1_3_experiments_update_experiments.
-
Deleting experiments. Notebook: 1_4_experiments_delete_experiments
-
Starting with MLflow runs. Notebook: 2_1_runs_create_run
-
Retrieving runs. Notebook: 2_2_runs_retrieve_run
-
Updating runs. Notebook: 2_3_runs_update_run
- video: 10. Runs, Updating run tags.
-
Nested runs. Notebook: 2_4_runs_nested_run
- video: 11. Runs, nested runs.
-
Delete a run. Notebook: 2_5_runs_delete_run
-
Starting with login functions. Notebook: 3_1_login_functions
-
Login ML models. Notebook: 3_2_logging_models
-
Model Signature. Notebook: 3_3_model_signature
-
Signature Enforcement. Notebook: 3_4_signture_enforcement
-
Custom functions. Notebook: 4_1_log_custom_functions
-
Custom functions context. Notebook: 4_2_custom_functions_context
-
Registering a model. Notebook: 5_1_registering_a_model
-
Update Registered Model. Notebook: 5_2_update_registered_model
-
Update model version. Notebook: 5_3_update_model_version
-
Retrieving Model Information. Notebook: 5_4_retrieve_model_info
-
Loading a registered model. Notebook: 5_5_loading_registered_models
-
Deleting registered models. Notebook: 5_6_delete_registered_model_info
-
-
Traditional ML Evaluation with MLflow
-
Model Evaluation with Mlflow. Notebook: 1_1_model_evaluation_with_mlflow
- video: 35. Model Evaluation.
- video: 36. Model Evaluation. Part 2.
- video: 37. Model Evaluation. Part 3
-
Defining custom metrics. Notebook: 1_2_custom_metrics
-
Custom artifacts. Notebook: 1_3_custom_artifacts
-
More about models and evaluation. Notebook: 1_4_evaluation_with_functions
- Example:
- Custom model (multimodel) Code: multimodel
-
-
- notebooks
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.
-
Iris classifier
-
Digit Recognition
-
Walmart Sales Regression
-
Diabetes Prediction
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
If you need to contact me, you can reach me at: