Practice
1. What will be the output of the following Python code snippet using NumPy for weighted sampling?
import numpy as np
np.random.seed(0)
weights = [0.1, 0.3, 0.6]
choices = ['A', 'B', 'C']
result = np.random.choice(choices, p=weights)
print(result)easy
Solution
Step 1: Understand weighted sampling.
np.random.choice with 'p' parameter uses specified probabilities for sampling.Step 2: Analyze the code.
Weights [0.1, 0.3, 0.6] mean 'C' is most likely, but not guaranteed.Final Answer:
Option A -> Option AQuick Check:
np.random.choice uses 'p' for weighted sampling [[check]]
Hint: np.random.choice uses 'p' for weighted sampling [[check]]
Common Mistakes:
2. You conducted an A/B test using the interleaving method, but the results are inconsistent with previous tests. What is the most likely cause?
medium
Solution
Step 1: Identify potential issues
Interleaving requires proper randomization to ensure fair comparison.Step 2: Eliminate wrong options
Data leakage and temporal trends are less likely in interleaving. Inadequate sample size affects power, not consistency.Final Answer:
Option D -> Option DQuick Check:
Randomization is key in interleaving. [OK]
Hint: Randomization is key in interleaving. [OK]
Common Mistakes:
3. 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:
4. In a scenario where computational resources are limited, which segmentation approach would be more appropriate to use and why?
medium
Solution
Step 1: Evaluate computational needs
Semantic segmentation is generally less computationally intensive than instance or panoptic segmentation.Step 2: Eliminate wrong options
Instance segmentation is more detailed and resource-heavy, panoptic combines both, and object detection is not segmentation.Final Answer:
Option C -> Option CQuick Check:
Semantic = Less computation than instance [OK]
Hint: Semantic = Less computation than instance [OK]
Common Mistakes:
5. You are tasked with designing a system to detect fraudulent transactions. Which approach is most appropriate given the need for adaptability to new fraud patterns?
hard
Solution
Step 1: Consider the need for adaptability.
Fraud patterns change over time, requiring a system that can learn and adapt.Step 2: Evaluate the options for adaptability.
Only a machine learning model that can be retrained offers the necessary adaptability.Final Answer:
Option D -> Option DQuick Check:
ML adapts, rules are static. [OK]
Hint: ML adapts, rules are static. [OK]
Common Mistakes:
