Practice
import numpy as np
from sklearn.model_selection import train_test_split
X = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
y = np.array([1, 1, 1, 1, 0, 0, 0, 0, 0, 0])
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
print(len(X_train), len(X_test))Solution
Step 1: Calculate the split sizes
With a test_size of 0.2, 20% of 10 samples go to the test set, i.e., 2 samples.Step 2: Determine the training set size
The remaining 80% (8 samples) go to the training set.Final Answer:
Option B -> Option BQuick Check:
80% train, 20% test split. [OK]
Solution
Step 1: Identify symptoms of degraded performance.
Continual learning models can overfit to recent data, especially if not managed properly.Step 2: Eliminate other causes.
The model is not receiving enough new data. is incorrect because lack of data would not cause degradation but stagnation. The model's architecture is too simple. is incorrect because architecture simplicity would limit initial performance, not degrade it over time. The model's learning rate is too high. is incorrect because a high learning rate would cause instability, not gradual degradation.Final Answer:
Option A -> Option AQuick Check:
Degradation often means overfitting. [OK]
Solution
Step 1: Identify effective drift detection
Monitoring statistical properties helps detect subtle changes in input data.Step 2: Eliminate wrong options
Use a static threshold on model accuracy. is reactive, not proactive. Rely on user feedback to identify issues. is unreliable and subjective. Increase the frequency of model retraining. addresses performance decay, not drift detection.Final Answer:
Option A -> Option AQuick Check:
Monitor input stats for drift detection [OK]
Solution
Step 1: Analyze the difference between offline and online environments.
Offline evaluation uses historical data, while online evaluation deals with live data, which may have a different distribution.Step 2: Eliminate other potential causes.
The model is overfitting to the training data. is incorrect because overfitting would likely affect both offline and online performance. The model's hyperparameters are not optimized. is incorrect because hyperparameter optimization affects both environments. The offline evaluation used an incorrect metric. is incorrect because using an incorrect metric would not cause a discrepancy between environments.Final Answer:
Option A -> Option AQuick Check:
Different data distribution online. [OK]
Solution
Step 1: Identify potential leakage sources in fraud detection
Using future-derived features can cause leakage.Step 2: Evaluate each option
Use cross-validation with shuffling to ensure robust performance. might introduce leakage if shuffling is inappropriate, Include all available transaction data up to the current date in the training set. risks future data leakage, Use a single train-test split to simplify the evaluation process. is simplistic and risky.Final Answer:
Option A -> Option AQuick Check:
Avoid future-derived features in training [OK]
