Practice
1. In the context of data labeling strategies, which method is best suited for generating large amounts of labeled data quickly but with potentially lower accuracy?
easy
Solution
Step 1: Understand the methods.
Human annotation is accurate but slow. Weak supervision uses heuristics or external data sources to generate labels quickly but may be less accurate.Step 2: Eliminate wrong options.
Programmatic labeling is similar to weak supervision but often requires more setup. Active learning involves human input and is not as fast.Final Answer:
Option A -> Option AQuick Check:
Weak supervision = fast, less accurate [OK]
Hint: Weak supervision = fast, less accurate [OK]
Common Mistakes:
2. Given the following Python code snippet using weak supervision, what will be the output?
import numpy as np
labels = np.array(['cat', 'dog', 'cat', 'dog'])
heuristics = np.array([1, 0, 1, 0])
weak_labels = np.where(heuristics == 1, 'cat', 'dog')
print(weak_labels)easy
Solution
Step 1: Analyze the code.
The code uses np.where to assign 'cat' where heuristics is 1 and 'dog' where it is 0.Step 2: Determine the output.
Since heuristics is [1, 0, 1, 0], the output will be ['cat', 'dog', 'cat', 'dog'].Final Answer:
Option B -> Option BQuick Check:
np.where logic: match heuristics [OK]
Hint: np.where logic: match heuristics [OK]
Common Mistakes:
3.
import numpy as np
from sklearn.feature_selection import SelectKBest, f_classif
X = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
y = np.array([1, 0, 1])
selector = SelectKBest(score_func=f_classif, k=2)
X_new = selector.fit_transform(X, y)
print(X_new)What does the above code output?easy
Solution
Step 1: Understand SelectKBest.
SelectKBest selects the top k features based on the highest scores from the scoring function.Step 2: Determine the output.
f_classif scores features based on ANOVA F-value. Here, features 2 and 3 have the highest scores.Final Answer:
Option A -> Option AQuick Check:
Top k features by score. [OK]
Hint: SelectKBest picks top k features by score. [OK]
Common Mistakes:
4. In the context of Naive Bayes, which of the following best describes the assumption of conditional independence?
easy
Solution
Step 1: Understand Conditional Independence
Naive Bayes assumes that features are independent given the class label.Step 2: Eliminate Wrong Options
Features are independent of the class label. suggests features are independent of the class label, which is incorrect. Features are dependent on each other given the class label. suggests dependency, which contradicts the assumption. Features are independent in all scenarios. suggests independence in all scenarios, which is overly broad.Final Answer:
Option B -> Option BQuick Check:
Naive Bayes assumes independence given class. [OK]
Hint: Naive Bayes assumes independence given class. [OK]
Common Mistakes:
5. When debugging a model with high variance, which approach is more suitable?
medium
Solution
Step 1: Identify high variance symptoms
High variance indicates overfitting, where the model performs well on training data but poorly on unseen data.Step 2: Choose the right approach
Adding more training data helps the model generalize better, reducing overfitting.Final Answer:
Option B -> Option BQuick Check:
High variance = more data [OK]
Hint: High variance = more data [OK]
Common Mistakes:
