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. Given the following Python code snippet, what will be the output if the model is trained with biased data?
from sklearn.metrics import accuracy_score
y_true = [0, 1, 1, 0, 1]
y_pred = [0, 1, 1, 0, 0]
accuracy = accuracy_score(y_true, y_pred)
print(accuracy)easy
Solution
Step 1: Calculate the accuracy.
Accuracy is the ratio of correctly predicted instances to the total instances. Here, 3 out of 5 predictions are correct.Step 2: Compute the accuracy.
Correct predictions: [0, 1, 1] -> 0.6Final Answer:
0.6 -> 0.6Quick Check:
Count correct predictions, divide by total. [OK]
Hint: Count correct predictions, divide by total. [OK]
Common Mistakes:
3. A CNN model is overfitting on the training data. Which of the following is a likely cause related to pooling layers?
medium
Solution
Step 1: Analyze pooling impact
Without pooling, feature maps remain large, increasing model complexity and risk of overfitting.Step 2: Eliminate wrong options
Pooling layers are too aggressive, losing important features is incorrect because aggressive pooling would reduce overfitting. Pooling layers are applied after every convolutional layer is incorrect as regular pooling helps reduce overfitting. Pooling layers use a large stride, reducing model complexity is incorrect because large strides reduce complexity, not increase it.Final Answer:
Option B -> Option BQuick Check:
No pooling increases overfitting risk. [OK]
Hint: No pooling increases overfitting risk. [OK]
Common Mistakes:
4. You are designing a transformer model for a language translation task. Which normalization technique would you choose and why?
hard
Solution
Step 1: Consider the architecture of transformers.
Transformers process sequences and often use self-attention mechanisms, where Layer Normalization is more effective.Step 2: Evaluate the benefits of Layer Normalization.
Layer Normalization normalizes across features, which is beneficial for the attention mechanism in transformers.Final Answer:
Option A -> Option AQuick Check:
Layer Norm fits transformers' self-attention. [OK]
Hint: Layer Norm fits transformers' self-attention. [OK]
Common Mistakes:
5. You need to apply model interpretability techniques to a real-time fraud detection system. Which approach is most suitable?
hard
Solution
Step 1: Consider real-time constraints.
Real-time systems require fast interpretability methods.Step 2: Evaluate each option.
SHAP and LIME are computationally expensive for real-time use. Attention mechanisms provide built-in interpretability without significant overhead.Final Answer:
Option A -> Option AQuick Check:
Attention is efficient for real-time interpretability. [OK]
Hint: Attention is efficient for real-time interpretability. [OK]
Common Mistakes:
