Practice
1. Given the following Python code, what will be the output when calculating the ROC-AUC for a highly imbalanced dataset?
from sklearn.metrics import roc_auc_score
y_true = [0, 0, 0, 0, 1]
y_scores = [0.1, 0.2, 0.3, 0.4, 0.9]
roc_auc = roc_auc_score(y_true, y_scores)
print(roc_auc)easy
Solution
Step 1: Calculate ROC-AUC
ROC-AUC measures the ability to distinguish between classes. Here, the positive class is perfectly ranked higher than the negative class.Step 2: Eliminate wrong options
0.5 would indicate random guessing. 0.75 and 0.9 are incorrect as the positive class is perfectly ranked.Final Answer:
Option A -> Option AQuick Check:
Perfect ranking gives ROC-AUC of 1.0. [OK]
Hint: Perfect ranking gives ROC-AUC of 1.0. [OK]
Common Mistakes:
2. 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:
3. You are tasked with designing a fraud detection system. How would you ensure that your model does not suffer from data leakage?
hard
Solution
Step 1: Identify potential leakage sources in fraud detection
Using future-derived features can cause leakage.Step 2: Evaluate each option
Use cross-validation with shuffling to ensure robust performance. might introduce leakage if shuffling is inappropriate, Include all available transaction data up to the current date in the training set. risks future data leakage, Use a single train-test split to simplify the evaluation process. is simplistic and risky.Final Answer:
Option A -> Option AQuick Check:
Avoid future-derived features in training [OK]
Hint: Avoid future-derived features in training [OK]
Common Mistakes:
4. You are tasked with designing a system to handle label drift in a real-time recommendation engine. Which approach would be most effective?
hard
Solution
Step 1: Identify the best approach for handling label drift.
A feedback loop allows the model to adapt to changes in label distribution by learning from recent interactions.Step 2: Eliminate wrong options.
Static mappings (Use a static label mapping based on historical data.) and increasing dataset size (Increase the size of the training dataset.) don't adapt to real-time changes. Feature selection (Apply feature selection to reduce dimensionality.) doesn't address label drift.Final Answer:
Option A -> Option AQuick Check:
Feedback loop adapts to label drift [OK]
Hint: Feedback loop adapts to label drift [OK]
Common Mistakes:
5. In a multilingual context, how can you adapt Word2Vec embeddings to handle multiple languages effectively?
hard
Solution
Step 1: Evaluate multilingual strategies
Multilingual BERT is designed to handle multiple languages effectively, unlike Word2Vec.Step 2: Eliminate wrong options
Train separate Word2Vec models for each language and concatenate the embeddings. doesn't capture cross-lingual semantics. Use a shared vocabulary across languages and train a single Word2Vec model. is impractical due to vocabulary differences. Translate all text to a single language before training Word2Vec. loses language-specific nuances.Final Answer:
Option A -> Option AQuick Check:
Multilingual BERT for cross-language tasks [OK]
Hint: Multilingual BERT for cross-language tasks [OK]
Common Mistakes:
