Practice
1. Given the following Python code snippet, what will be the output if the input data has undergone covariate drift?
import numpy as np
from sklearn.linear_model import LinearRegression
X_train = np.array([[1, 2], [2, 3], [3, 4]])
y_train = np.array([3, 5, 7])
model = LinearRegression().fit(X_train, y_train)
X_test = np.array([[4, 5], [5, 6]])
predictions = model.predict(X_test)
print(predictions)easy
Solution
Step 1: Understand the impact of covariate drift.
Covariate drift affects the input distribution, leading to biased predictions.Step 2: Eliminate wrong options.
The model won't throw an error (The model will throw an error.) and predictions won't be accurate (The predictions will be accurate.) or unaffected (The predictions will be unaffected by covariate drift.) due to drift.Final Answer:
Option D -> Option DQuick Check:
Covariate drift biases predictions [OK]
Hint: Covariate drift biases predictions [OK]
Common Mistakes:
2. In the context of why machine learning exists, which of the following problems is most suitable for a machine learning approach rather than a rule-based system?
easy
Solution
Step 1: Identify the nature of the problem.
Predicting the next word in a sentence involves understanding context and patterns, which are complex and not easily defined by rules.Step 2: Eliminate rule-based problems.
Options A, C, and D are deterministic and can be solved with explicit algorithms.Final Answer:
Option A -> Option AQuick Check:
ML for patterns, rules for logic. [OK]
Hint: ML excels at pattern recognition, not deterministic logic. [OK]
Common Mistakes:
3. A model performs well on the validation set but poorly on the test set. What is the most likely cause?
medium
Solution
Step 1: Identify the discrepancy
Good validation performance but poor test performance suggests a mismatch between sets.Step 2: Eliminate less likely causes
The model is underfitting the data. is incorrect as underfitting would affect both sets. The validation set is too small. is less likely unless the validation set is extremely small. The model has too many parameters. would likely affect both sets similarly.Final Answer:
Option A -> Option AQuick Check:
Mismatch between validation and test sets. [OK]
Hint: Mismatch between validation and test sets. [OK]
Common Mistakes:
4. You are tasked with designing a model for a real-time translation app. Which architecture would you choose and why?
hard
Solution
Step 1: Consider the requirements of real-time translation.
Real-time translation requires handling long-range dependencies efficiently.Step 2: Evaluate each architecture.
Use a standard RNN for its simplicity and ease of implementation. is incorrect as RNNs are slow for long sequences. Use a CNN-based model for its speed in processing sequences. is incorrect because CNNs struggle with sequence dependencies. Use a hybrid RNN-CNN model to leverage both sequence processing and speed. is incorrect as hybrid models add complexity without solving dependency issues.Final Answer:
Option D -> Option DQuick Check:
Transformers excel in long-range dependencies. [OK]
Hint: Transformers excel in long-range dependencies. [OK]
Common Mistakes:
5. How would you adapt K-Fold cross-validation for a dataset with a temporal component and class imbalance?
hard
Solution
Step 1: Address both temporal order and class imbalance.
Time Series Split respects temporal order, and manual balancing addresses class imbalance.Step 2: Eliminate wrong options.
Standard K-Fold (A) ignores temporal order, Stratified K-Fold (B) doesn't respect temporal order, Leave-One-Out (D) is computationally expensive and doesn't address temporal order.Final Answer:
Option D -> Option DQuick Check:
Time series + imbalance = manual balance. [OK]
Hint: Time series + imbalance = manual balance. [OK]
Common Mistakes:
