|
|
# How to get started with MLflow
|
|
|
|
|
|
*work in progress*
|
|
|
|
|
|
The purpose of this page is to give you an idea what MLflow can be used for, which aspects to consider and best practices.
|
|
|
|
|
|
---
|
|
|
|
|
|
#### 0. Set Up Your ML Project with [Tracking](https://mlflow.org/docs/latest/tracking/) in Mind
|
|
|
- Use a clean project structure with separate folders for data, code, outputs, and models.
|
|
|
- Use a virtual environment to manage dependencies.
|
|
|
- [Install MLflow and test that the tracking UI works locally or on a server.](Tutorials/MLflow/How-to-set-up-MLflow)
|
|
|
|
|
|
#### 1. Organise Experiments
|
|
|
- Define an experiment name to group all related model runs. Think of an [experiment as a folder](https://mlflow.org/docs/latest/traditional-ml/hyperparameter-tuning-with-child-runs/part1-child-runs/) containing different versions of your model with varying settings.
|
|
|
- Use descriptive run names and tags.
|
|
|
- Organise runs using the concept of [Parent and Child Runs](https://mlflow.org/docs/latest/traditional-ml/hyperparameter-tuning-with-child-runs/part1-child-runs/) in MLflow, a feature that provides a hierarchical structure when doing hyperparameter searches.
|
|
|
|
|
|
#### 3. Track Runs During Training
|
|
|
- Log everything relevant to reproduce or understand the run later. <br>
|
|
|
Info: Most ML libraries (e.g. [Keras](https://mlflow.org/docs/latest/deep-learning/keras/)/[TensorFlow](https://mlflow.org/docs/latest/deep-learning/tensorflow/), [PyTorch](https://mlflow.org/docs/latest/deep-learning/pytorch/guide/), Scikit-learn, ...) support the [autologging feature of MLflow](https://mlflow.org/docs/latest/tracking/autolog/):
|
|
|
- For each model training run: <br>
|
|
|
* Log the model's parameters (e.g., learning rate)<br>
|
|
|
* Log performance metrics (e.g., accuracy or loss)<br>
|
|
|
* Save and log any important artifacts (e.g., plots, config files, or trained models)<br>
|
|
|
Note: Avoid displaying figures inside notebooks, instead [log the files and view them in the UI](https://mlflow.org/docs/latest/traditional-ml/hyperparameter-tuning-with-child-runs/notebooks/logging-plots-in-mlflow). Use scripts or pipeline functions that can be reused and versioned.
|
|
|
|
|
|
#### 4. Use the MLflow UI to Compare Results
|
|
|
- Browse and filter model runs
|
|
|
- Compare different configurations side by side
|
|
|
- View plots and metrics to [choose the best model](https://mlflow.org/docs/latest/getting-started/quickstart-2/)
|
|
|
|
|
|
#### 6. Collaborate and Share Results
|
|
|
- Use a shared tracking server so others on your team can log to and view the same experiment database.
|
|
|
- Store artifacts and models in shared or centralized locations.
|
|
|
|
|
|
#### 7. Reuse and Deploy Models
|
|
|
- Save your trained models via MLflow for later use.
|
|
|
- Optionally, register the best models and serve them with MLflow's model serving features. |
|
|
\ No newline at end of file |