Practice
1.
from sklearn.tree import DecisionTreeClassifier
import numpy as np
X = np.array([[0, 0], [1, 1], [1, 0], [0, 1]])
y = np.array([0, 1, 1, 0])
clf = DecisionTreeClassifier(criterion='gini')
clf.fit(X, y)
print(clf.predict([[0, 0], [1, 1]]))What is the output of the above code?easy
Solution
Step 1: Understand the training data.
The data is perfectly separable, and the decision tree will learn to classify based on the given labels.Step 2: Predict using the trained model.
For input [0, 0], the label is 0, and for [1, 1], the label is 1.Final Answer:
Option C -> Option CQuick Check:
Check training labels for predictions. [OK]
Hint: Check training labels for predictions. [OK]
Common Mistakes:
2. A neural network model is overfitting on the training data. What is the most likely cause?
medium
Solution
Step 1: Identify symptoms of overfitting
Overfitting occurs when a model performs well on training data but poorly on unseen data.Step 2: Determine the cause
A complex model with too many parameters relative to the data size is a common cause of overfitting.Final Answer:
Option B -> Option BQuick Check:
Complex models overfit small data. [OK]
Hint: Complex models overfit small data. [OK]
Common Mistakes:
3. When should you prefer using Gini Impurity over Entropy in decision trees?
medium
Solution
Step 1: Compare computational efficiency.
Gini Impurity is computationally less intensive than Entropy.Step 2: Eliminate wrong options.
Interpretability is not affected by the choice, imbalance handling is not specific to Gini, and both can handle continuous features.Final Answer:
Option A -> Option AQuick Check:
Gini is faster than Entropy. [OK]
Hint: Gini is faster than Entropy. [OK]
Common Mistakes:
4. A Graph Neural Network model is underperforming on a node classification task. The model's architecture and hyperparameters seem appropriate. What could be a potential cause of this issue?
medium
Solution
Step 1: Analyze the graph structure
Isolated nodes can disrupt message passing, leading to poor performance.Step 2: Eliminate other causes
Overfitting, learning rate, and batch size issues would manifest differently.Final Answer:
Option D -> Option DQuick Check:
Check for isolated nodes disrupting message passing. [check]
Hint: Check for isolated nodes disrupting message passing. [check]
Common Mistakes:
5. You are tasked with designing a recommendation system for a high-dimensional dataset. Which approach would best handle the curse of dimensionality while maintaining performance?
hard
Solution
Step 1: Identify the challenge of high dimensions.
Matrix factorization reduces dimensionality effectively.Step 2: Eliminate wrong options.
Implement a simple content-based filtering system. doesn't reduce dimensions. Apply a deep learning model with many hidden layers. may overfit due to high dimensions. Use a rule-based system to manually curate recommendations. is not scalable for large datasets.Final Answer:
Option B -> Option BQuick Check:
Matrix factorization reduces dimensions, aids recommendations. [OK]
Hint: Matrix factorization reduces dimensions, aids recommendations. [OK]
Common Mistakes:
