Practice
1. Given the following Python code snippet, what is the output?
import numpy as np
features = np.array([1, 2, 3, 4])
normalized = (features - np.mean(features)) / np.std(features)
print(normalized)easy
Solution
Step 1: Understand the normalization process.
Normalization involves subtracting the mean and dividing by the standard deviation.Step 2: Calculate the mean and standard deviation.
Mean = 2.5, Standard deviation = 1.1180.Step 3: Apply normalization.
Normalized values are [-1.5, -0.5, 0.5, 1.5].Final Answer:
Option A -> Option AQuick Check:
Normalize: subtract mean, divide by std. [OK]
Hint: Normalize: subtract mean, divide by std. [OK]
Common Mistakes:
2. In the context of Graph Neural Networks, which component is primarily responsible for aggregating information from neighboring nodes?
easy
Solution
Step 1: Identify the role of each component
The message passing mechanism is designed to aggregate information from neighboring nodes in a graph.Step 2: Eliminate wrong options
Activation functions, dropout layers, and batch normalization do not specifically aggregate information from neighboring nodes.Final Answer:
Option C -> Option CQuick Check:
Message passing aggregates neighbor info in GNNs. [check]
Hint: Message passing aggregates neighbor info in GNNs. [check]
Common Mistakes:
3. In the context of evaluating a recommendation system, which of the following best describes why offline evaluation metrics might disagree with online performance?
easy
Solution
Step 1: Understand the difference between offline and online evaluation.
Offline evaluation uses historical data and predefined metrics, while online evaluation captures real-time user interactions.Step 2: Eliminate wrong options.
Offline metrics are always more accurate than online metrics. is incorrect because offline metrics are not inherently more accurate. Online metrics are biased due to data leakage. is incorrect because online metrics are not biased due to data leakage; they reflect real-world interactions. Offline metrics are influenced by server latency. is incorrect because server latency affects online performance, not offline metrics.Final Answer:
Option D -> Option DQuick Check:
Offline misses real user dynamics. [OK]
Hint: Offline misses real user dynamics. [OK]
Common Mistakes:
4. In a dataset with highly imbalanced classes, which sampling strategy is most appropriate to ensure each class is represented proportionally in the sample?
easy
Solution
Step 1: Identify the need for proportional representation.
In imbalanced datasets, it's crucial to maintain class proportions to avoid bias.Step 2: Eliminate inappropriate strategies.
Random Sampling (A) doesn't guarantee class proportions. Reservoir Sampling (C) is for streaming data, not class balance. Weighted Sampling (D) adjusts for importance, not proportions.Final Answer:
Option A -> Option AQuick Check:
Stratified = Proportional representation [OK]
Hint: Stratified = Proportional representation [OK]
Common Mistakes:
5. When should you prefer using Gini Impurity over Entropy in decision trees?
medium
Solution
Step 1: Compare computational efficiency.
Gini Impurity is computationally less intensive than Entropy.Step 2: Eliminate wrong options.
Interpretability is not affected by the choice, imbalance handling is not specific to Gini, and both can handle continuous features.Final Answer:
Option A -> Option AQuick Check:
Gini is faster than Entropy. [OK]
Hint: Gini is faster than Entropy. [OK]
Common Mistakes:
