Practice
1. Given the following Python code, what will be the output if the model is overfitting?
from sklearn.metrics import accuracy_score
train_preds = model.predict(X_train)
val_preds = model.predict(X_val)
train_acc = accuracy_score(y_train, train_preds)
val_acc = accuracy_score(y_val, val_preds)
print(f'Train Accuracy: {train_acc}, Validation Accuracy: {val_acc}')easy
Solution
Step 1: Understand overfitting output
Overfitting results in high training accuracy but low validation accuracy.Step 2: Eliminate wrong options
Train Accuracy: 0.95, Validation Accuracy: 0.95 suggests good generalization, Train Accuracy: 0.60, Validation Accuracy: 0.60 suggests underfitting, and Train Accuracy: 0.60, Validation Accuracy: 0.95 is unrealistic for overfitting.Final Answer:
Option A -> Option AQuick Check:
High train, low validation = overfitting [OK]
Hint: High train, low validation = overfitting [OK]
Common Mistakes:
2. You are dealing with a dataset where both covariate and concept drift are suspected. Which approach is more suitable for handling this scenario?
medium
Solution
Step 1: Identify the best approach for handling drift.
Periodic model retraining helps adapt to both covariate and concept drift.Step 2: Eliminate wrong options.
Static models (Use a static model trained on historical data.) and single validation sets (Use a single validation set for model evaluation.) don't adapt to drift. Feature scaling (Rely on feature scaling to handle the drift.) doesn't address drift.Final Answer:
Option B -> Option BQuick Check:
Retrain models to adapt to drift [OK]
Hint: Retrain models to adapt to drift [OK]
Common Mistakes:
3. When choosing between polynomial features and interaction terms for a linear model, which is more appropriate when the dataset is small and why?
medium
Solution
Step 1: Consider dataset size and model complexity.
Small datasets are prone to overfitting with complex models.Step 2: Evaluate the impact of each option.
Polynomial features (A, C) increase complexity significantly, leading to overfitting. Interaction terms (B, D) add complexity but less than polynomial features, making them more suitable for small datasets.Final Answer:
Option D -> Option DQuick Check:
Small data: prefer interaction terms to avoid overfitting. [OK]
Hint: Small data: prefer interaction terms to avoid overfitting. [OK]
Common Mistakes:
4. In a scenario where computational resources are limited, which optimizer would you choose for faster convergence and why?
medium
Solution
Step 1: Consider optimizer efficiency.
Adam combines the benefits of both AdaGrad and RMSProp, leading to faster convergence.Step 2: Evaluate resource constraints.
Adam is computationally efficient and converges faster than SGD with momentum and AdaGrad.Final Answer:
Option A -> Option AQuick Check:
Adam is efficient for limited resources. [check]
Hint: Adam is efficient for limited resources. [check]
Common Mistakes:
5. How would you apply slice-based evaluation to improve a sentiment analysis model for a multilingual dataset?
hard
Solution
Step 1: Understand the application of slice-based evaluation
Slice-based evaluation helps identify performance issues in specific data subsets.Step 2: Apply to multilingual context
Creating slices based on language allows for targeted performance analysis and improvements.Final Answer:
Option B -> Option BQuick Check:
Slice by language for targeted analysis. [OK]
Hint: Slice by language for targeted analysis. [OK]
Common Mistakes:
