Practice
1.
from sklearn.linear_model import Ridge
import numpy as np
X = np.array([[1, 2], [3, 4], [5, 6]])
y = np.array([1, 2, 3])
model = Ridge(alpha=0.0)
model.fit(X, y)
print(model.coef_)What does this code output?easy
Solution
Step 1: Understand the effect of alpha=0 in Ridge.
Setting alpha to zero in Ridge regression makes it equivalent to ordinary least squares.Step 2: Eliminate wrong options.
Alpha=0 does not cause an error. Zero coefficients would require L1 regularization. Random coefficients are incorrect as the model still fits the data.Final Answer:
Option B -> Option BQuick Check:
Alpha=0 in Ridge = OLS. [OK]
Hint: Alpha=0 in Ridge = OLS. [OK]
Common Mistakes:
2. A model using Batch Normalization is showing unstable training behavior with fluctuating loss. What is the most likely cause?
medium
Solution
Step 1: Identify the role of batch size in Batch Normalization.
Batch Normalization relies on accurate batch statistics, which can be unreliable with small batch sizes.Step 2: Eliminate other causes.
The learning rate is too high, causing instability. is a common issue but not specific to Batch Norm. The model architecture is too deep, causing vanishing gradients. is unrelated to normalization. The dataset is imbalanced, affecting the normalization process. affects model performance but not directly related to Batch Norm instability.Final Answer:
Option A -> Option AQuick Check:
Small batch size causes unstable Batch Norm. [OK]
Hint: Small batch size causes unstable Batch Norm. [OK]
Common Mistakes:
3. When choosing between online and offline data collection for a recommendation system, which factor is most critical for deciding to use online data collection?
medium
Solution
Step 1: Identify the key factor for online data collection
Online data collection is crucial when real-time feedback is needed to update recommendations dynamically.Step 2: Eliminate factors not specific to online collection
Options B, C, and D do not specifically require online data collection; they can be addressed with offline methods.Final Answer:
Option A -> Option AQuick Check:
Real-time needs = online collection. [OK]
Hint: Real-time needs = online collection. [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. How would you adapt K-Fold cross-validation for a dataset with a temporal component and class imbalance?
hard
Solution
Step 1: Address both temporal order and class imbalance.
Time Series Split respects temporal order, and manual balancing addresses class imbalance.Step 2: Eliminate wrong options.
Standard K-Fold (A) ignores temporal order, Stratified K-Fold (B) doesn't respect temporal order, Leave-One-Out (D) is computationally expensive and doesn't address temporal order.Final Answer:
Option D -> Option DQuick Check:
Time series + imbalance = manual balance. [OK]
Hint: Time series + imbalance = manual balance. [OK]
Common Mistakes:
