Practice
1. Given the following Python code, what will be the output?
import numpy as np
from sklearn.model_selection import train_test_split
X = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
y = np.array([1, 1, 1, 1, 0, 0, 0, 0, 0, 0])
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
print(len(X_train), len(X_test))easy
Solution
Step 1: Calculate the split sizes
With a test_size of 0.2, 20% of 10 samples go to the test set, i.e., 2 samples.Step 2: Determine the training set size
The remaining 80% (8 samples) go to the training set.Final Answer:
Option B -> Option BQuick Check:
80% train, 20% test split. [OK]
Hint: 80% train, 20% test split. [OK]
Common Mistakes:
2. Which dimensionality reduction technique is most suitable for visualizing high-dimensional data while preserving local structures?
easy
Solution
Step 1: Understand the purpose of each technique
PCA is used for linear dimensionality reduction, UMAP is similar to t-SNE but faster, and LDA is for supervised dimensionality reduction.Step 2: Identify the technique that preserves local structures
t-SNE is specifically designed to preserve local structures in high-dimensional data.Final Answer:
Option A -> Option AQuick Check:
t-SNE for local structures [OK]
Hint: t-SNE for local structures [OK]
Common Mistakes:
3. In the context of data collection for machine learning, which scenario best describes an offline data collection approach?
easy
Solution
Step 1: Identify offline data collection characteristics
Offline data collection involves gathering data that has already been generated and stored, not in real-time.Step 2: Eliminate real-time options
Options A, C, and D involve real-time or near-real-time data collection, which is characteristic of online data collection.Final Answer:
Option D -> Option DQuick Check:
Offline = historical, stored data. [OK]
Hint: Offline = historical, stored data. [OK]
Common Mistakes:
4. You conducted an A/B test using the interleaving method, but the results are inconsistent with previous tests. What is the most likely cause?
medium
Solution
Step 1: Identify potential issues
Interleaving requires proper randomization to ensure fair comparison.Step 2: Eliminate wrong options
Data leakage and temporal trends are less likely in interleaving. Inadequate sample size affects power, not consistency.Final Answer:
Option D -> Option DQuick Check:
Randomization is key in interleaving. [OK]
Hint: Randomization is key in interleaving. [OK]
Common Mistakes:
5. 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:
