How to Use MLflow UI for Tracking Machine Learning Experiments
To use the
MLflow UI, start the UI server by running mlflow ui in your terminal. Then open http://localhost:5000 in your browser to view and compare your machine learning experiment runs, metrics, parameters, and artifacts.Syntax
The basic command to start the MLflow UI is mlflow ui. This launches a local web server that hosts the UI. You can specify options like --port to change the port number and --backend-store-uri to point to a specific experiment tracking database.
mlflow ui: Starts the UI server on default port 5000.--port 1234: Changes the port to 1234.--backend-store-uri: Sets the location of the tracking data (e.g., a local folder or database).
bash
mlflow ui --port 5000 --backend-store-uri ./mlrunsExample
This example shows how to start the MLflow UI and log a simple experiment using Python. After running the experiment, open the UI in your browser to see the logged runs, parameters, and metrics.
python
import mlflow # Start an MLflow run with mlflow.start_run(): mlflow.log_param("param1", 5) mlflow.log_metric("accuracy", 0.85) # To start the UI, run this command in your terminal: # mlflow ui # Then open http://localhost:5000 in your browser to see the experiment.
Output
2024/06/01 12:00:00 INFO mlflow.tracking.fluent: Experiment with name 'Default' does not exist. Creating a new experiment.
Common Pitfalls
- UI not starting: Make sure MLflow is installed and you run
mlflow uiin the correct environment. - Wrong port: If port 5000 is busy, use
--portto change it. - No runs shown: Confirm your experiment logs are saved in the
mlrunsfolder or the backend store you specified. - Browser access: The UI runs locally, so open
http://localhost:5000in the same machine's browser.
bash
## Wrong way: UI on default port but port busy mlflow ui ## Right way: Change port to 1234 mlflow ui --port 1234
Quick Reference
| Command/Option | Description |
|---|---|
| mlflow ui | Start MLflow UI on default port 5000 |
| --port | Change the port number for the UI server |
| --backend-store-uri | Set the location of experiment tracking data |
| http://localhost:5000 | Default URL to access the MLflow UI in browser |
| mlflow.start_run() | Start logging an experiment run in Python |
| mlflow.log_param(key, value) | Log a parameter for the current run |
| mlflow.log_metric(key, value) | Log a metric for the current run |
Key Takeaways
Start MLflow UI by running 'mlflow ui' in your terminal to open the web interface.
Access the UI at 'http://localhost:5000' to view and compare experiment runs.
Use '--port' option if the default port 5000 is busy or unavailable.
Ensure your experiment data is logged correctly to see runs in the UI.
MLflow UI helps track parameters, metrics, and artifacts visually for easy comparison.