Practice
1. What is the time complexity of performing K-Fold cross-validation on a dataset with n samples and k folds?
easy
Solution
Step 1: Analyze K-Fold process
Each fold requires training on (k-1)/k of the data and testing on 1/k.Step 2: Eliminate wrong options
O(n) ignores the k factor. O(n^2) and D overestimate complexity.Final Answer:
Option C -> Option CQuick Check:
K-Fold complexity is O(kn). [OK]
Hint: K-Fold complexity is O(kn). [OK]
Common Mistakes:
2. What does the following Python code output when computing the ROC curve?
from sklearn.metrics import roc_curve
import numpy as np
y_true = np.array([0, 0, 1, 1])
y_scores = np.array([0.1, 0.4, 0.35, 0.8])
fpr, tpr, thresholds = roc_curve(y_true, y_scores)
print(fpr, tpr, thresholds)easy
Solution
Step 1: Understand ROC curve output
The ROC curve function returns false positive rates (fpr), true positive rates (tpr), and thresholds.Step 2: Analyze the code
Given the scores and true labels, the ROC curve is calculated correctly, resulting in fpr, tpr, and thresholds as in array([0. , 0.5, 1. ]), array([0. , 0.5, 1. ]), array([0.8, 0.35, 0.1]).Final Answer:
Option C -> Option CQuick Check:
ROC curve outputs fpr, tpr, thresholds [OK]
Hint: ROC curve outputs fpr, tpr, thresholds [OK]
Common Mistakes:
3. In a pipeline that includes flipping, cropping, and normalizing images, where should normalization be applied for best results?
medium
Solution
Step 1: Understand the impact of operations
Normalization should be the last step to ensure consistent scaling.Step 2: Evaluate each option
Applying normalization last ensures it accounts for all transformations.Final Answer:
Option D -> Option DQuick Check:
Normalize last for consistent scaling. [OK]
Hint: Normalize last for consistent scaling. [OK]
Common Mistakes:
4. In a custom dropout layer implementation, how should you modify the forward pass for inference mode to ensure correct scaling?
medium
Solution
Step 1: Understand Inference Scaling
During inference, inputs should be scaled by dividing by (1 - dropout_rate) to maintain expected values.Step 2: Eliminate Wrong Options
Apply the same dropout mask as in training. incorrectly applies dropout during inference. Multiply inputs by (1 - dropout_rate). scales incorrectly. Use a different dropout rate for inference. suggests changing dropout rate, which is not standard practice.Final Answer:
Option A -> Option AQuick Check:
Scale by dividing during inference. [OK]
Hint: Scale by dividing during inference. [OK]
Common Mistakes:
5. In your implementation of K-Means, the algorithm is not converging. What is the most likely cause?
medium
Solution
Step 1: Identify convergence issues
Poorly chosen initial centroids can lead to non-convergence as they may not represent the data well.Step 2: Eliminate wrong options
The number of clusters is too large. is incorrect because a large number of clusters doesn't prevent convergence. The dataset is too small. is incorrect as a small dataset doesn't inherently cause non-convergence. The distance metric is incorrect. is incorrect if the metric is consistent.Final Answer:
Option C -> Option CQuick Check:
Check initial centroids for convergence issues. [OK]
Hint: Check initial centroids for convergence issues. [OK]
Common Mistakes:
