Machine Learning Associate · 9% of the exam

MLflow Tracking: free practice questions

5 sample questions from our 23-question bank for this domain — answers and explanations included. These are the same scenario-based style as the real Databricks exam.

1. A senior data scientist wants to programmatically retrieve all MLflow runs in an experiment that achieved a validation AUC greater than 0.90 and used a max_depth parameter of 6, then sort them by AUC descending. Which MlflowClient code snippet correctly accomplishes this?

  • A. client.search_runs(experiment_ids=['123'], filter_string="metrics.val_auc > 0.90 and params.max_depth = '6'", order_by=['metrics.val_auc DESC'])✓ Correct
  • B. client.search_runs(experiment_ids=['123'], filter_string="metrics.val_auc > 0.90 and params.max_depth = 6", order_by=['metrics.val_auc DESC'])
  • C. client.list_runs(experiment_id='123', filter_string="metrics.val_auc > 0.90", params={'max_depth': 6}, sort_by='val_auc')
  • D. client.get_experiment('123').runs.filter(val_auc__gt=0.90, max_depth=6).order_by('-val_auc')
Explanation

Option A is correct: in MLflow's search_runs() filter syntax, parameter values must be compared as strings (quoted), even if they represent numbers, while metric values are compared as numeric literals. The filter string "metrics.val_auc > 0.90 and params.max_depth = '6'" correctly uses the string comparison for the param and numeric comparison for the metric. The order_by list with 'metrics.val_auc DESC' correctly sorts results. Option B is incorrect because params.max_depth = 6 uses a numeric literal for a parameter, but all parameter values in MLflow are stored as strings; this will raise a query parsing error. Option C is incorrect because MlflowClient has no list_runs() method with those arguments; the correct method is search_runs(). Option D is incorrect; MlflowClient does not expose a Django ORM-style queryset API — it does not have .filter() or .order_by() chaining methods on experiment objects.

2. Which of the following statements correctly describes the relationship between an MLflow **experiment** and an MLflow **run**?

  • A. An experiment is a single training execution; a run is a collection of related experiments
  • B. An experiment is a named container that groups related runs; each run captures parameters, metrics, and artifacts from one execution✓ Correct
  • C. A run is a named container that groups related experiments; each experiment captures parameters, metrics, and artifacts
  • D. Experiments and runs are interchangeable terms in MLflow; both refer to a single model training execution
Explanation

In MLflow, an experiment is the top-level organizational unit — a named container (with a unique ID and optional artifact location) used to group related runs. A run is a single execution of ML code captured within an experiment, storing parameters, metrics, tags, and artifact references. Option A reverses the hierarchy. Option C also reverses the hierarchy, describing a run as the container and an experiment as the execution unit, which is backwards. Option D is incorrect because experiments and runs are distinct concepts with a strict parent-child relationship.

3. A team is performing hyperparameter tuning with 50 child runs, each a variation of the same model. They want a clean hierarchy in the MLflow UI where all child runs are grouped under a single parent run. Which code pattern correctly implements this nested run structure?

  • A. Start all 50 runs with `mlflow.start_run()` sequentially; MLflow automatically groups runs created in the same experiment
  • B. Use `mlflow.start_run(nested=True)` for all 50 runs without an enclosing parent run context
  • C. Open a parent run with `mlflow.start_run()`, then open each child run with `mlflow.start_run(nested=True)` inside the parent's context✓ Correct
  • D. Use `mlflow.set_experiment_tag('parent_run', run_id)` on each child run to link them to the parent
Explanation

MLflow supports nested runs through the `nested=True` parameter of mlflow.start_run(). The correct pattern is: (1) open a parent run using `with mlflow.start_run() as parent_run:`, then (2) inside that context, open each child run with `with mlflow.start_run(nested=True):`. This establishes an explicit parent-child relationship visible in the MLflow UI. Option A is wrong because sequentially starting runs in the same experiment does NOT create a hierarchy — they appear as sibling runs. Option B is wrong because using nested=True without an enclosing active parent run will cause an error or treat the run as a top-level run, not a child. Option D is wrong because mlflow.set_experiment_tag() sets tags at the experiment level, not on individual runs, and does not create a run hierarchy.

4. A MLOps engineer registers a model in the MLflow Model Registry and wants to designate the best-performing version as the production model using the modern MLflow 2.x approach. Which method correctly assigns a **Champion** alias to version 3 of a registered model named `fraud_detector`?

  • A. client.transition_model_version_stage(name='fraud_detector', version=3, stage='Production')
  • B. client.set_registered_model_alias(name='fraud_detector', alias='Champion', version=3)✓ Correct
  • C. client.set_model_version_tag(name='fraud_detector', version=3, key='alias', value='Champion')
  • D. client.update_model_version(name='fraud_detector', version=3, description='Champion')
Explanation

In MLflow 2.x, the recommended way to designate a model version for a role (such as production) is through **aliases** using client.set_registered_model_alias(). This assigns a human-readable alias (e.g., 'Champion') to a specific version number, allowing code to reference the model by alias rather than hard-coded version number. Option A uses the older stage-based API (Staging/Production/Archived) which is deprecated in MLflow 2.x in favor of aliases. Option C is incorrect because set_model_version_tag() adds a key-value metadata tag to a version — it does not create a functional alias that can be used to load the model by name. Option D is incorrect because update_model_version() is used to update the description field of a model version, not to assign an alias.

5. A machine learning engineer wants to enable MLflow autologging for a scikit-learn model training pipeline. Which single line of code, placed BEFORE the model is fitted, correctly enables autologging for scikit-learn?

  • A. mlflow.sklearn.autolog()✓ Correct
  • B. mlflow.autolog(framework='sklearn')
  • C. mlflow.enable_autologging('sklearn')
  • D. mlflow.log_model(model, 'sklearn')
Explanation

mlflow.sklearn.autolog() is the correct framework-specific autologging call for scikit-learn. It automatically logs hyperparameters, metrics (e.g., training score), and the fitted model artifact when a scikit-learn estimator's fit() method is called. Option B is wrong because mlflow.autolog() (the global shortcut) does not accept a 'framework' keyword argument in its standard API. Option C is wrong because mlflow.enable_autologging() does not exist as an MLflow function. Option D is wrong because mlflow.log_model() is used to manually log an already-trained model artifact, not to enable autologging.

18 more questions in this domain

Practice the full bank with instant grading, flashcards, and a timed mock exam.

Start practicing free
MLflow Tracking — Free Machine Learning Associate Practice Questions | DataCertPrep — Certification Prep