Practice
1. Given the following Python code snippet, what will be the output?
import numpy as np
from sklearn.utils import resample
X = np.array([[1, 2], [3, 4], [5, 6]])
y = np.array([0, 0, 1])
X_resampled, y_resampled = resample(X, y, replace=True, n_samples=6, stratify=y)
print(y_resampled)easy
Solution
Step 1: Understand stratified resampling.
Stratified resampling maintains the class distribution in the resampled dataset.Step 2: Calculate expected output.
Original distribution is 2:1, so resampled should be 4:2.Final Answer:
Option B -> Option BQuick Check:
Stratified resampling keeps class ratios. [OK]
Hint: Stratified resampling keeps class ratios. [OK]
Common Mistakes:
2. You have a dataset with a large number of features and limited computational resources. Which feature selection method is most appropriate?
medium
Solution
Step 1: Consider computational efficiency.
Filter methods are computationally inexpensive as they do not involve training models.Step 2: Eliminate wrong options.
Wrapper methods and recursive feature elimination are computationally intensive. Embedded methods require model training, which can be resource-heavy.Final Answer:
Option D -> Option DQuick Check:
Filter = low cost, no model. [OK]
Hint: Filter methods are computationally cheap. [OK]
Common Mistakes:
3. 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:
4. A deep network is underperforming on a complex task despite having sufficient data. What is a likely cause?
medium
Solution
Step 1: Analyze the symptoms
Underperformance on complex tasks often indicates a lack of capacity to capture hierarchical features, suggesting the network might be too shallow.Step 2: Eliminate wrong options
The network is too deep, causing overfitting. is incorrect because overfitting would show high training accuracy. The learning rate is too high, causing divergence. is incorrect because divergence would cause erratic loss. The batch size is too small, causing slow convergence. is incorrect because slow convergence would not cause underperformance if training is complete.Final Answer:
Option D -> Option DQuick Check:
Shallow networks miss hierarchies. [OK]
Hint: Shallow networks miss hierarchies. [OK]
Common Mistakes:
5. You are tasked with debugging a production model that suddenly started underperforming. Which approach is most effective in systematically diagnosing the issue?
hard
Solution
Step 1: Identify potential causes
Sudden performance drops often relate to changes in data or environment.Step 2: Choose a systematic approach
Checking for changes in data preprocessing is a logical first step to identify if the input data has changed.Final Answer:
Option A -> Option AQuick Check:
Sudden drop = check data changes [OK]
Hint: Sudden drop = check data changes [OK]
Common Mistakes:
