Practice
1. In the context of A/B testing for ML models, which method is best suited for ensuring that temporal trends do not bias the results?
easy
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]
Hint: Interleaving reduces temporal bias. [OK]
Common Mistakes:
2. Given the following Python code snippet, what will be the output?
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)easy
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]
Hint: Stratified resampling keeps class ratios. [OK]
Common Mistakes:
3.
import numpy as np
from sklearn.neighbors import NearestNeighbors
X = np.array([[1, 2], [3, 4], [5, 6]])
knn = NearestNeighbors(n_neighbors=2)
knn.fit(X)
distances, indices = knn.kneighbors([[1, 2]])
print(indices)What does this code output?easy
Solution
Step 1: Understand kneighbors output
The code finds the 2 nearest neighbors of [1, 2] in X.Step 2: Calculate distances
[1, 2] is closest to itself (index 0) and then to [3, 4] (index 1).Final Answer:
Option C -> Option CQuick Check:
Self is always nearest. [OK]
Hint: Self is always nearest. [OK]
Common Mistakes:
4. You have a dataset with 50% missing values in a feature. Should you impute or drop this feature, and why?
medium
Solution
Step 1: Assess the impact of missing data
50% missing data can lead to unreliable imputations.Step 2: Evaluate the trade-off
Imputation with 50% missing data can introduce significant noise, making dropping the feature a better choice.Final Answer:
Option A -> Option AQuick Check:
50% missing? Drop it! [OK]
Hint: 50% missing? Drop it! [OK]
Common Mistakes:
5. You need to design a system using RAG prompting for a real-time question-answering application. Which approach ensures the system remains efficient and accurate?
hard
Solution
Step 1: Understand RAG efficiency
For real-time applications, updating documents based on interactions ensures relevance and accuracy.Step 2: Eliminate wrong options
Use a static set of documents for retrieval to ensure consistency. lacks adaptability. Rely solely on the model's pre-trained knowledge without retrieval. ignores the retrieval component. Use a large, diverse document set without updates to avoid bias. risks outdated information.Final Answer:
Option C -> Option CQuick Check:
Update documents for real-time RAG efficiency. [OK]
Hint: Update documents for real-time RAG efficiency. [OK]
Common Mistakes:
