Bird
Raised Fist0
MLOpsdevops~20 mins

MLflow setup and basics in MLOps - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
MLflow Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
MLflow Tracking Server Start Output
You run the command mlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./artifacts. What output indicates the server started successfully?
MLOps
mlflow server --backend-store-uri sqlite:///mlflow.db --default-artifact-root ./artifacts
A2024/01/01 12:00:00 WARNING mlflow.server: Artifact root not found
B2024/01/01 12:00:00 INFO mlflow.server: Starting MLflow server at http://127.0.0.1:5000
CSyntaxError: invalid syntax in command
DError: Could not find mlflow.db file
Attempts:
2 left
💡 Hint
Look for a log line that confirms the server is running and listening.
🧠 Conceptual
intermediate
1:30remaining
MLflow Experiment Default Behavior
When you run mlflow.start_run() without specifying an experiment, what happens?
AMLflow saves the run locally without associating it to any experiment.
BMLflow throws an error because experiment must be specified.
CMLflow logs the run to the last used experiment automatically.
DMLflow creates a new experiment named 'Default' if it does not exist and logs the run there.
Attempts:
2 left
💡 Hint
Think about what MLflow does when no experiment is given.
🔀 Workflow
advanced
2:30remaining
Correct MLflow Run Logging Sequence
Arrange these steps in the correct order to log parameters and metrics in MLflow:
A2,3,1,4
B1,2,3,4
C2,1,3,4
D1,3,2,4
Attempts:
2 left
💡 Hint
You must start a run before logging anything, and end it last.
Troubleshoot
advanced
2:00remaining
MLflow Artifact Storage Issue
You configured MLflow with --default-artifact-root ./artifacts but your artifacts are not saved after runs. What is the most likely cause?
AThe artifacts directory does not exist or MLflow lacks write permission.
BThe backend store URI must be a remote database, not SQLite.
CMLflow requires an absolute path for artifact root, relative paths are not supported.
DMLflow only saves artifacts if you call <code>mlflow.save_artifact()</code> explicitly.
Attempts:
2 left
💡 Hint
Check file system permissions and directory existence.
Best Practice
expert
3:00remaining
MLflow Model Versioning Strategy
Which approach best supports reproducibility and easy rollback when using MLflow model registry in a team environment?
ARegister each model version with a unique version number and add descriptive tags for context.
BOverwrite the same model name every time to keep only the latest version.
CStore models only locally and avoid using the MLflow model registry to reduce complexity.
DUse a single experiment for all models and track versions manually in a separate document.
Attempts:
2 left
💡 Hint
Think about how teams can track and revert models easily.

Practice

(1/5)
1. What is the primary purpose of MLflow in machine learning projects?
easy
A. To deploy machine learning models to mobile devices
B. To write machine learning algorithms from scratch
C. To create datasets for training models
D. To track and organize machine learning experiments

Solution

  1. Step 1: Understand MLflow's role

    MLflow is designed to help manage and track experiments, not to build models or datasets.
  2. Step 2: Identify the correct purpose

    Tracking and organizing experiments is the core feature of MLflow.
  3. Final Answer:

    To track and organize machine learning experiments -> Option D
  4. Quick Check:

    MLflow = experiment tracking [OK]
Hint: Remember MLflow tracks experiments, not builds models [OK]
Common Mistakes:
  • Confusing MLflow with model building libraries
  • Thinking MLflow creates datasets
  • Assuming MLflow deploys models directly
2. Which command correctly installs MLflow using pip?
easy
A. pip install mlflow
B. pip get mlflow
C. install mlflow pip
D. pip mlflow install

Solution

  1. Step 1: Recall pip install syntax

    The correct syntax to install a package is 'pip install package_name'.
  2. Step 2: Match the command

    Only 'pip install mlflow' matches the correct syntax.
  3. Final Answer:

    pip install mlflow -> Option A
  4. Quick Check:

    pip install + package = correct [OK]
Hint: Use 'pip install' followed by package name [OK]
Common Mistakes:
  • Using incorrect order of words
  • Using 'pip get' instead of 'pip install'
  • Omitting 'install' keyword
3. What happens when you run the command mlflow ui in your terminal?
medium
A. It starts a web interface to view and compare ML experiments
B. It installs MLflow on your system
C. It runs your machine learning model training
D. It deletes all previous MLflow experiments

Solution

  1. Step 1: Understand the 'mlflow ui' command

    This command launches the MLflow tracking server's web interface.
  2. Step 2: Identify the effect

    The UI lets users view and compare experiments visually in a browser.
  3. Final Answer:

    It starts a web interface to view and compare ML experiments -> Option A
  4. Quick Check:

    mlflow ui = launch web UI [OK]
Hint: Think 'ui' means user interface for experiments [OK]
Common Mistakes:
  • Confusing UI launch with installation
  • Assuming it runs training automatically
  • Thinking it deletes experiments
4. You try to start MLflow UI with mlflow ui but get an error saying 'command not found'. What is the most likely cause?
medium
A. You need to run 'mlflow start' instead
B. Your Python version is too new for MLflow
C. MLflow is not installed or not in your system PATH
D. You must run the command inside a Jupyter notebook

Solution

  1. Step 1: Analyze the error message

    'command not found' means the system cannot locate the 'mlflow' command.
  2. Step 2: Identify common causes

    This usually happens if MLflow is not installed or its executable is not in the system PATH.
  3. Final Answer:

    MLflow is not installed or not in your system PATH -> Option C
  4. Quick Check:

    Command not found = missing install or PATH [OK]
Hint: Check if MLflow is installed and in PATH [OK]
Common Mistakes:
  • Trying wrong commands like 'mlflow start'
  • Blaming Python version without checking install
  • Assuming it must run inside Jupyter
5. You want to create a new MLflow experiment named 'MyExperiment' and log a parameter 'alpha' with value 0.5 in a Python script. Which code snippet correctly does this?
hard
A. import mlflow mlflow.create_experiment('MyExperiment') mlflow.log_param('alpha', 0.5)
B. import mlflow mlflow.set_experiment('MyExperiment') with mlflow.start_run(): mlflow.log_param('alpha', 0.5)
C. import mlflow mlflow.start_experiment('MyExperiment') mlflow.log_param('alpha', 0.5)
D. import mlflow mlflow.set_experiment('MyExperiment') mlflow.log_param('alpha', 0.5)

Solution

  1. Step 1: Set the experiment name

    Use mlflow.set_experiment('MyExperiment') to select or create the experiment.
  2. Step 2: Start a run and log parameters

    Use 'with mlflow.start_run():' block to start a run, then log parameters inside it.
  3. Step 3: Identify correct snippet

    import mlflow mlflow.set_experiment('MyExperiment') with mlflow.start_run(): mlflow.log_param('alpha', 0.5) correctly uses set_experiment, start_run context, and logs parameter.
  4. Final Answer:

    import mlflow mlflow.set_experiment('MyExperiment') with mlflow.start_run(): mlflow.log_param('alpha', 0.5) -> Option B
  5. Quick Check:

    Set experiment + start run + log param = correct [OK]
Hint: Always start a run before logging parameters [OK]
Common Mistakes:
  • Logging parameters outside a run
  • Using non-existent functions like create_experiment
  • Not using 'with' block for start_run