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 PyTorch code snippet for an LSTM layer, what is the shape of the output
h_n?
import torch
lstm = torch.nn.LSTM(input_size=10, hidden_size=20, num_layers=2)
input = torch.randn(5, 3, 10)
output, (h_n, c_n) = lstm(input)easy
Solution
Step 1: Understand LSTM output shapes.
Theh_nshape is (num_layers, batch_size, hidden_size).Step 2: Apply the given parameters.
Here, num_layers=2, batch_size=3, hidden_size=20, so the shape is (2, 3, 20).Final Answer:
Option B -> Option BQuick Check:
h_n shape: (layers, batch, hidden). [OK]
Hint: h_n shape: (layers, batch, hidden). [OK]
Common Mistakes:
3. A decision tree model is overfitting the training data. What is the most likely cause?
medium
Solution
Step 1: Identify overfitting causes.
Overfitting often occurs when the model is too complex, such as a deep tree.Step 2: Eliminate wrong options.
A shallow tree would underfit, a small dataset affects generalization but not directly overfitting, and uninformative features would lead to poor performance, not overfitting.Final Answer:
Option D -> Option DQuick Check:
Deep trees overfit easily. [OK]
Hint: Deep trees overfit easily. [OK]
Common Mistakes:
4. When comparing two models using statistical significance, which approach is more appropriate if you have a small sample size?
medium
Solution
Step 1: Consider sample size constraints
With small sample sizes, non-parametric tests are more reliable as they do not assume normal distribution.Step 2: Eliminate inappropriate tests
Use a t-test assuming equal variances. assumes equal variances which may not hold. Use a z-test assuming normal distribution. assumes normal distribution, which is unreliable with small samples. Use a chi-squared test for independence. is for categorical data, not model comparison.Final Answer:
Option B -> Option BQuick Check:
Small samples? Use non-parametric tests [OK]
Hint: Small samples? Use non-parametric tests [OK]
Common Mistakes:
5. A high-dimensional dataset is causing a model to perform poorly. The model's accuracy is unexpectedly low. What is the most likely root cause?
medium
Solution
Step 1: Identify the impact of high dimensions.
High dimensions often lead to data sparsity, affecting generalization.Step 2: Eliminate wrong options.
The model is underfitting due to insufficient complexity. is about model complexity, not data sparsity. The model is overfitting due to too many parameters. is about overfitting, not generalization. The learning rate is too high, causing unstable training. is about training stability, not generalization.Final Answer:
Option A -> Option AQuick Check:
High dimensions lead to sparsity, hurting generalization. [OK]
Hint: High dimensions lead to sparsity, hurting generalization. [OK]
Common Mistakes:
