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. Which regularization technique is most suitable for feature selection in a linear regression model?
easy
Solution
Step 1: Identify the purpose of feature selection.
L1 Lasso regularization can shrink some coefficients to zero, effectively selecting features.Step 2: Eliminate wrong options.
L2 Ridge does not shrink coefficients to zero. Elastic Net combines L1 and L2 but is not as direct for feature selection. Dropout is not used in linear regression.Final Answer:
Option A -> Option AQuick Check:
L1 Lasso zeros coefficients for selection. [OK]
Hint: L1 Lasso zeros coefficients for selection. [OK]
Common Mistakes:
3. When deciding between Few-Shot and Chain-of-Thought prompting, which scenario is best suited for Chain-of-Thought?
medium
Solution
Step 1: Understand Chain-of-Thought
Chain-of-Thought is best for tasks requiring complex reasoning.Step 2: Eliminate wrong options
When the task involves simple factual recall. is incorrect as factual recall doesn't need reasoning. When the model needs to be fine-tuned with a few examples. is about Few-Shot, not Chain-of-Thought. When the task requires generating creative content. is unrelated to reasoning.Final Answer:
Option B -> Option BQuick Check:
Use Chain-of-Thought for complex reasoning tasks. [OK]
Hint: Use Chain-of-Thought for complex reasoning tasks. [OK]
Common Mistakes:
4. A reinforcement learning model is not improving its performance despite extensive training. What is the most likely cause?
medium
Solution
Step 1: Identify the issue.
In reinforcement learning, a poorly defined reward function can lead to suboptimal learning.Step 2: Eliminate wrong options.
The model has too many parameters. is incorrect because parameter count affects complexity, not learning direction. The training data is not labeled. is irrelevant as RL doesn't require labeled data. The model is overfitting to the training data. is less likely as overfitting would show initial improvement.Final Answer:
Option D -> Option DQuick Check:
Poor reward function -> Poor learning [OK]
Hint: Poor reward function -> Poor learning [OK]
Common Mistakes:
5. When deciding between using a pretrained model or training from scratch for a specific task, which scenario favors training from scratch?
medium
Solution
Step 1: Identify when pretraining is less beneficial.
Pretraining is less useful when no relevant pretrained models exist.Step 2: Eliminate wrong options.
The task is similar to the one the pretrained model was trained on. favors using pretrained models due to task similarity. The task has a very large and diverse dataset available. also favors pretrained models due to data availability. The task requires real-time inference with minimal latency. is unrelated to the choice between pretraining and training from scratch.Final Answer:
Option A -> Option AQuick Check:
No pretrained model? Train from scratch. [check]
Hint: No pretrained model? Train from scratch. [check]
Common Mistakes:
