Practice
Solution
Step 1: Understand the methods
Interleaving method allows for simultaneous comparison, reducing temporal bias.Step 2: Eliminate wrong options
Holdout and cross-validation do not address temporal trends. Causal inference is more about understanding causality than handling temporal trends.Final Answer:
Option B -> Option BQuick Check:
Interleaving reduces temporal bias. [OK]
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)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]
import numpy as np
from scipy.stats import norm
confidence_level = 0.95
z_score = norm.ppf((1 + confidence_level) / 2)
print(round(z_score, 2))Solution
Step 1: Calculate z-score for 95% confidence
The z-score for a 95% confidence level is calculated using the inverse of the cumulative distribution function (CDF) for a standard normal distribution.Step 2: Evaluate code output
The code correctly calculates the z-score as 1.96 for a 95% confidence interval.Final Answer:
Option C -> Option CQuick Check:
95% confidence z-score is 1.96 [OK]
Solution
Step 1: Analyze potential causes of performance issues
Data discrepancies are a common cause of unexpected model performance.Step 2: Eliminate less likely causes
Incorrect dataset usage is more likely than versioning or packaging issues.Final Answer:
Option D -> Option DQuick Check:
Check dataset consistency [OK]
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]
