The MLflow UI and API support searching runs within a single experiment or a group of experiments
using a search filter API. This API is a simplified version of the SQL
Table of Contents
A search filter is one or more expressions joined by the
The syntax does not support
OR. Each expression has three parts: an identifier on
the left-hand side (LHS), a comparator, and constant on the right-hand side (RHS).
Search for the subset of runs with logged accuracy metric greater than 0.92.
metrics.accuracy > 0.92
Search for runs created using a Logistic Regression model, a learning rate (lambda) of 0.001, and recorded error metric under 0.05.
params.model = "LogisticRegression" and params.lambda = "0.001" and metrics.error <= 0.05
Search for all failed runs.
attributes.status = "FAILED"
Required in the LHS of a search expression. Signifies an entity to compare against.
An identifier has two parts separated by a period: the type of the entity and the name of the entity. The type of the entity is
tags. The entity name can contain alphanumeric characters and special characters.
This section describes supported entity names and how to specify such names in search expressions.
In this section:
When a metric, parameter, or tag name contains a special character like hyphen, space, period, and so on, enclose the entity name in double quotes or backticks.
Unlike SQL syntax for column names, MLflow allows logging metrics, parameters, and tags names that have a leading number. If an entity name contains a leading number, enclose the entity name in double quotes. For example:
metrics."2019-04-02 error rate"
You can search using two run attributes contained in
artifact_uri. Both attributes have string values. Other fields in
mlflow.entities.RunInfo are not searchable.
- The experiment ID is implicitly selected by the search API.
- A run’s
lifecycle_stageattribute is not allowed because it is already encoded as a part of the API’s
run_view_typefield. To search for runs using
run_id, it is more efficient to use
end_timeattributes are not supported.
There are two classes of comparators: numeric and string.
- Numeric comparators (
- String comparators (
The search syntax requires the RHS of the expression to be a constant. The type of the constant depends on LHS.
- If LHS is a metric, the RHS must be an integer or float number.
- If LHS is a parameter or tag, the RHS must be a string constant enclosed in single or double quotes.
The MLflow UI supports searching runs contained within the current experiment. To search runs across multiple experiments, use one of the client APIs.
mlflow.search_runs() API to search programmatically.
You can specify the list of columns to order by (for example, “metrics.rmse”) in the
The column can contain an optional
ASC value; the default is
The default ordering is to sort by
start_time DESC, then
For example, to get all active runs from experiments IDs 3, 4, and 17 that used a CNN model with 10 layers and had a prediction accuracy of 94.5% or higher, use:
from mlflow.tracking.client import MlflowClient from mlflow.entities import ViewType query = "params.model = 'CNN' and params.layers = '10' and metrics.'prediction accuracy' >= 0.945" runs = MlflowClient().search_runs(["3", "4", "17"], query, ViewType.ACTIVE_ONLY)
To search all known experiments for any MLflow runs created using the Inception model architecture:
from mlflow.tracking.client import MlflowClient from mlflow.entities import ViewType all_experiments = [exp.experiment_id for exp in MlflowClient().list_experiments()] runs = MlflowClient().search_runs(all_experiments, "params.model = 'Inception'", ViewType.ALL)
The Java API is similar to Python API.
List<Long> experimentIds = Arrays.asList("1", "2", "4", "8"); List<RunInfo> searchResult = client.searchRuns(experimentIds, "metrics.accuracy_score < 99.90");