Practice
1. 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:
2.
import numpy as np
from sklearn.model_selection import cross_val_score
from sklearn.tree import DecisionTreeClassifier
X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
y = np.array([0, 1, 0, 1])
model = DecisionTreeClassifier()
scores = cross_val_score(model, X, y, cv=2)
print(scores)What does this code output?easy
Solution
Step 1: Understand cross-validation output
Cross-validation with cv=2 splits the data into two folds, returning an array of two scores.Step 2: Eliminate wrong options
An error because the dataset is too small for cross-validation. is incorrect because the code runs without error. A single accuracy score for the entire dataset. is incorrect because cross-validation returns multiple scores. An array of four accuracy scores, one for each data point. is incorrect because the number of scores equals the number of folds, not data points.Final Answer:
Option A -> Option AQuick Check:
Cross-validation returns scores per fold. [OK]
Hint: Cross-validation returns scores per fold. [OK]
Common Mistakes:
3. A model trained with focal loss is not improving on the validation set. What is the most likely cause?
medium
Solution
Step 1: Identify focal loss dependency.
Focal loss requires tuning of its parameters (gamma, alpha) to be effective.Step 2: Eliminate other causes.
High learning rate and underfitting are general issues, not specific to focal loss. Dataset imbalance is assumed.Final Answer:
Option A -> Option AQuick Check:
Focal loss needs parameter tuning. [OK]
Hint: Focal loss needs parameter tuning. [OK]
Common Mistakes:
4. A KNN model is performing poorly on a high-dimensional dataset. What is the most likely cause?
medium
Solution
Step 1: Consider high-dimensional effects
In high dimensions, distance metrics often become less effective.Step 2: Eliminate wrong options
The model has too few neighbors. is incorrect as increasing neighbors may not help. The dataset is too small. is wrong because size isn't the main issue. The model is overfitting due to too many neighbors. is incorrect as overfitting is less likely with many neighbors.Final Answer:
Option B -> Option BQuick Check:
High dimensions dilute distance metrics. [OK]
Hint: High dimensions dilute distance metrics. [OK]
Common Mistakes:
5. You need to implement a CI/CD pipeline for an ML model that requires frequent updates and real-time predictions. Which approach best handles these requirements?
hard
Solution
Step 1: Match requirements to approaches.
Frequent updates and real-time predictions require a system that can adapt quickly and deploy changes continuously.Step 2: Evaluate each option.
Batch processing (A) and scheduled deployments (D) are too slow. Manual deployment (C) is inefficient. Online learning (B) supports continuous updates and real-time predictions.Final Answer:
Option A -> Option AQuick Check:
Online learning = real-time updates. [OK]
Hint: Online learning = real-time updates. [OK]
Common Mistakes:
