Querying runs

Introduction to MLflow

Weston Bassler

Senior MLOps Engineer

Model data

data

1 istock.com
Introduction to MLflow

Runs data

runs-data

Introduction to MLflow

Searching runs

mlflow.search_runs()

pandas

1 https://pandas.pydata.org/
Introduction to MLflow

Output format

 #   Column                         Non-Null Count  Dtype
 0   run_id                         6 non-null      object
 1   experiment_id                  6 non-null      object
 2   status                         6 non-null      object
 3   artifact_uri                   6 non-null      object
 4   start_time                     6 non-null      datetime64[ns, UTC]
 5   end_time                       5 non-null      datetime64[ns, UTC]
 6   metrics.test                   1 non-null      float64
 7   metrics.metric_2               3 non-null      float64
 8   metrics.metric_1               3 non-null      float64
 9   params.param_1                 3 non-null      object
 10  params.random_state            3 non-null      object
 11  params.n_estimators            3 non-null      object
 12  tags.mlflow.user               6 non-null      object
 13  tags.mlflow.runName            6 non-null      object
 14  tags.mlflow.source.type        6 non-null      object
 15  tags.mlflow.source.name        6 non-null      object
 16  tags.mlflow.log-model.history  3 non-null      object
dtypes: datetime64[ns, UTC](2), float64(3), object(12)
memory usage: 944.0+ bytes
Introduction to MLflow

Filtering run searches

  • max_results - maximum number of results to return.

  • order_by - column(s) to sort in ASCending or DESCending order.

  • filter_string - string based query.

  • experiment_names - name(s) of experiments to query.

Introduction to MLflow

Tracking UI

tracking-ui

Introduction to MLflow

Search runs example

import mlflow

# Filter string f1_score_filter = "metrics.f1_score > 0.60"
# Search runs mlflow.search_runs(experiment_names=["Insurance Experiment"], filter_string=f1_score_filter, order_by=["metrics.precision_score DESC"])
Introduction to MLflow

Example output

# Search runs from Insurance Experiment
mlflow.search_runs(experiment_names=["Insurance Experiment"],
    filter_string=f1_score_filter, 
    order_by=["metrics.precision_score DESC"])
                             run_id experiment_id  ... tags.mlflow.source.type tags.mlflow.user
0  90407e29a5aa4a31954bed874c7d4337            27  ...                   LOCAL           user
1  c335c0b16a5d4cf398aaa7189362b577            27  ...                   LOCAL           user

Introduction to MLflow

Let's practice!

Introduction to MLflow

Preparing Video For Download...