Practice
1. Given the following Python code snippet, what will be the output if the dataset contains data leakage?
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
model = LogisticRegression()
model.fit(X_train, y_train)
y_pred = model.predict(X_test)
print(accuracy_score(y_test, y_pred))easy
Solution
Step 1: Understand the impact of data leakage
Data leakage often results in overly optimistic performance metrics.Step 2: Analyze the code behavior
The code will execute without errors, but if leakage exists, the model will perform better than it should.Final Answer:
Option D -> Option DQuick Check:
Leakage inflates accuracy [OK]
Hint: Leakage inflates accuracy [OK]
Common Mistakes:
2. In the context of Few-Shot prompting, which of the following best describes its primary purpose?
easy
Solution
Step 1: Understand Few-Shot Prompting
Few-Shot prompting involves providing a model with a few examples to guide its responses.Step 2: Eliminate wrong options
To train a model from scratch with minimal data. is incorrect as Few-Shot does not train from scratch. To fine-tune a pre-trained model with a large dataset. is about fine-tuning, not Few-Shot. To ensure a model generates deterministic outputs. is unrelated to Few-Shot's purpose.Final Answer:
Option A -> Option AQuick Check:
Few examples guide responses in Few-Shot. [OK]
Hint: Few examples guide responses in Few-Shot. [OK]
Common Mistakes:
3. A model trained on a dataset is performing exceptionally well on the test set but poorly on new unseen data. What is the most likely cause?
medium
Solution
Step 1: Analyze the symptoms
High test performance but poor real-world performance suggests leakage.Step 2: Eliminate other causes
The model is overfitting due to too many parameters. would affect both test and real-world data, The model has not been trained for enough epochs. would not cause high test performance, The feature scaling was not applied correctly. would affect all data equally.Final Answer:
Option B -> Option BQuick Check:
High test, low real-world = leakage [OK]
Hint: High test, low real-world = leakage [OK]
Common Mistakes:
4. A model trained with Adam optimizer is not converging. What is the most likely cause?
medium
Solution
Step 1: Identify common issues with Adam.
Adam can be sensitive to high learning rates, causing divergence.Step 2: Eliminate less likely causes.
Adam handles non-convex problems well, and batch size/weight decay are less likely to cause non-convergence.Final Answer:
Option B -> Option BQuick Check:
High lr can cause Adam to diverge. [check]
Hint: High lr can cause Adam to diverge. [check]
Common Mistakes:
5. You need to label a large dataset for a new domain with minimal existing labeled data. Which strategy should you apply and why?
hard
Solution
Step 1: Understand the domain challenge.
New domains often lack labeled data, making programmatic labeling a flexible choice.Step 2: Evaluate other strategies.
Human annotation is accurate but slow. Weak supervision requires existing data sources, which may not be available. Active learning still requires some initial labeled data.Final Answer:
Option C -> Option CQuick Check:
New domain = Programmatic Labeling [OK]
Hint: New domain = Programmatic Labeling [OK]
Common Mistakes:
