Practice
1. Given the following MLflow code snippet, what will be the output?
import mlflow
mlflow.start_run()
mlflow.log_param('alpha', 0.5)
mlflow.log_metric('accuracy', 0.85)
mlflow.end_run()What happens when you run this code?easy
Solution
Step 1: Understand MLflow run lifecycle
MLflow allows logging parameters and metrics within an active run.Step 2: Analyze the code
The code starts a run, logs a parameter and a metric, and ends the run correctly.Final Answer:
Option A -> Option AQuick Check:
Active run = Log success [OK]
Hint: Active run = Log success [OK]
Common Mistakes:
2.
import numpy as np
from sklearn.preprocessing import StandardScaler
X = np.array([[1, 2], [3, 4], [5, 6]])
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
print(X_scaled.mean(axis=0))What does this code output?easy
Solution
Step 1: Understand standardization.
StandardScaler standardizes features by removing the mean and scaling to unit variance.Step 2: Calculate the mean of standardized data.
After standardization, the mean of each feature should be 0.Final Answer:
Option C -> Option CQuick Check:
StandardScaler centers data to mean 0. [OK]
Hint: StandardScaler centers data to mean 0. [OK]
Common Mistakes:
3. A model trained with weak supervision is underperforming. What is the most likely cause?
medium
Solution
Step 1: Identify the weak supervision challenge.
Weak supervision relies on heuristics, which can be a source of error if too simplistic.Step 2: Eliminate other causes.
Model complexity and dataset size are less likely to be the primary issue in weak supervision. Learning rate affects training stability, not heuristic quality.Final Answer:
Option A -> Option AQuick Check:
Weak supervision = heuristic quality [OK]
Hint: Weak supervision = heuristic quality [OK]
Common Mistakes:
4. In a scenario where computational resources are limited, which approach is more suitable for hyperparameter tuning and why?
medium
Solution
Step 1: Evaluate resource constraints
Cross-validation is computationally expensive but provides robust tuning.Step 2: Eliminate less suitable options
Use a single train-test split to save resources. risks overfitting. Use a train-validation split and skip the test set. skips the test set, risking unseen data performance. Use a larger test set to ensure model generalization. misallocates resources to testing rather than tuning.Final Answer:
Option C -> Option CQuick Check:
Cross-validation ensures robust tuning despite cost. [OK]
Hint: Cross-validation ensures robust tuning despite cost. [OK]
Common Mistakes:
5. You need to reduce the dimensionality of a dataset with 10,000 features for a real-time application. Which technique is more suitable and why?
medium
Solution
Step 1: Consider computational efficiency
Real-time applications require fast computations.Step 2: Evaluate each option
t-SNE is computationally expensive, UMAP is faster but still slower than PCA, and LDA is not suitable for unsupervised tasks.Final Answer:
Option B -> Option BQuick Check:
PCA for speed in large datasets [OK]
Hint: PCA for speed in large datasets [OK]
Common Mistakes:
