Practice
1. In the context of decision trees, which metric is used to measure the impurity of a node?
easy
Solution
Step 1: Identify the metric for node impurity.
Gini Impurity is specifically used to measure the impurity of a node in decision trees.Step 2: Eliminate wrong options.
Entropy is used for information gain, Mean Squared Error is for regression tasks, and Information Gain is a criterion for splitting, not impurity.Final Answer:
Option B -> Option BQuick Check:
Gini measures impurity in nodes. [OK]
Hint: Gini measures impurity in nodes. [OK]
Common Mistakes:
2. Given the following Python code snippet for a segmentation task, what will be the output shape if the input image shape is (256, 256, 3) and the model outputs a segmentation map with 10 classes?
import numpy as np
input_image = np.random.rand(256, 256, 3)
model_output = np.random.rand(256, 256, 10)easy
Solution
Step 1: Understand the model output
The model outputs a segmentation map with a shape corresponding to the input spatial dimensions and the number of classes.Step 2: Eliminate wrong options
(256, 256, 3) is the input shape, (256, 256, 1) implies binary segmentation, and (256, 256) lacks class dimension.Final Answer:
Option A -> Option AQuick Check:
Output shape = Input spatial + class channels [OK]
Hint: Output shape = Input spatial + class channels [OK]
Common Mistakes:
3. 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:
4. How would you adapt KNN for a real-time recommendation system with millions of users and items?
hard
Solution
Step 1: Consider scalability and speed
Approximate methods like locality-sensitive hashing are suitable for large-scale, real-time systems.Step 2: Eliminate wrong options
Use exact KNN with a large number of neighbors. is incorrect due to inefficiency. Reduce the number of features to improve speed. is wrong as feature reduction alone may not suffice. Use a single global model for all users. is incorrect because personalization is key in recommendations.Final Answer:
Option A -> Option AQuick Check:
Approximate methods for real-time scale. [OK]
Hint: Approximate methods for real-time scale. [OK]
Common Mistakes:
5. You need to implement a real-time recommendation system. Which approach is most suitable given the need for low latency and high throughput?
hard
Solution
Step 1: Identify the requirements.
Real-time systems require low latency and high throughput.Step 2: Choose the approach that meets these requirements.
Online learning with a streaming framework allows for real-time updates and low latency.Final Answer:
Option A -> Option AQuick Check:
Streaming fits real-time needs. [OK]
Hint: Streaming fits real-time needs. [OK]
Common Mistakes:
