Practice
1. Given the following Python code snippet, what will be the output if the model's performance has decayed due to data drift?
import numpy as np
from sklearn.metrics import accuracy_score
y_true = np.array([1, 0, 1, 1, 0])
y_pred = np.array([0, 0, 1, 0, 0])
accuracy = accuracy_score(y_true, y_pred)
print(f'Accuracy: {accuracy:.2f}')
easy
Solution
Step 1: Calculate accuracy
Compare y_true and y_pred: only 2 out of 5 predictions are correct.Step 2: Compute accuracy
Accuracy = 2/5 = 0.40.Final Answer:
Option A -> Option AQuick Check:
Count correct predictions, divide by total [OK]
Hint: Count correct predictions, divide by total [OK]
Common Mistakes:
2.
import numpy as np
x = np.array([1, 2, 3])
y = np.array([4, 5, 6])
result = np.dot(x, y)
print(result)What does this code output?easy
Solution
Step 1: Understand the dot product operation.
The dot product of two vectors is the sum of the products of their corresponding elements.Step 2: Calculate the dot product.
(1*4) + (2*5) + (3*6) = 32.Final Answer:
Option C -> Option CQuick Check:
Dot product sums element-wise products. [OK]
Hint: Dot product sums element-wise products. [OK]
Common Mistakes:
3. A model performs well overall but poorly on a specific slice of data. What is the most likely cause?
medium
Solution
Step 1: Analyze the problem
Poor performance on a specific slice often indicates distribution mismatch.Step 2: Eliminate wrong options
The model is overfitting to the training data. is incorrect as overfitting would affect overall performance. The model has too many parameters. is unrelated to slice-specific issues. The learning rate is too high. affects convergence, not slice performance.Final Answer:
Option A -> Option AQuick Check:
Slice mismatch = distribution issue. [OK]
Hint: Slice mismatch = distribution issue. [OK]
Common Mistakes:
4. When choosing between SHAP and LIME for model interpretability, which scenario makes SHAP a better choice?
medium
Solution
Step 1: Compare SHAP and LIME.
SHAP provides consistent and accurate explanations for complex models, while LIME is faster but less accurate for non-linear models.Step 2: Match the scenario to the technique.
SHAP is preferred for complex, non-linear models due to its accuracy and consistency.Final Answer:
Option D -> Option DQuick Check:
SHAP excels with complex, non-linear models. [OK]
Hint: SHAP excels with complex, non-linear models. [OK]
Common Mistakes:
5. You need to label a large dataset for a new domain with minimal existing labeled data. Which strategy should you apply and why?
hard
Solution
Step 1: Understand the domain challenge.
New domains often lack labeled data, making programmatic labeling a flexible choice.Step 2: Evaluate other strategies.
Human annotation is accurate but slow. Weak supervision requires existing data sources, which may not be available. Active learning still requires some initial labeled data.Final Answer:
Option C -> Option CQuick Check:
New domain = Programmatic Labeling [OK]
Hint: New domain = Programmatic Labeling [OK]
Common Mistakes:
