Practice
import numpy as np
from sklearn.decomposition import PCA
X = np.array([[1, 2], [3, 4], [5, 6]])
pca = PCA(n_components=1)
X_transformed = pca.fit_transform(X)
print(X_transformed)What is the shape of X_transformed?Solution
Step 1: Understand PCA output shape
PCA reduces the dimensionality of the data to the specified number of components.Step 2: Calculate the expected shape
With 3 samples and 1 component, the output shape is (3, 1).Final Answer:
Option D -> Option DQuick Check:
PCA output shape: (n_samples, n_components) [OK]
Solution
Step 1: Identify XGBoost's unique features
XGBoost is known for its regularization capabilities, which help prevent overfitting.Step 2: Eliminate wrong options
XGBoost uses bagging to improve model accuracy. is incorrect because XGBoost does not use bagging; it uses boosting. XGBoost is designed to handle missing data by default. is incorrect because while XGBoost can handle missing data, this is not its key advantage over traditional boosting. XGBoost uses a single decision tree for predictions. is incorrect because XGBoost uses an ensemble of trees, not a single tree.Final Answer:
Option D -> Option DQuick Check:
XGBoost = Regularization advantage [OK]
Solution
Step 1: Identify the role of positional encodings.
Positional encodings provide sequence order information, crucial for context.Step 2: Eliminate wrong options.
The model's attention heads are not properly initialized. is incorrect as initialization affects convergence, not context. The model's feedforward layers are too shallow. is incorrect because feedforward depth affects capacity, not context. The model's dropout rate is too high. is incorrect as dropout affects regularization, not context.Final Answer:
Option B -> Option BQuick Check:
Positional encodings ensure context. [OK]
Solution
Step 1: Understand receptive fields
Smaller receptive fields in initial layers help capture fine-grained local features, which are crucial for understanding detailed patterns.Step 2: Eliminate wrong options
To capture more global features early on is incorrect because global features are captured in deeper layers. To reduce the computational cost of the network is incorrect as smaller receptive fields don't necessarily reduce computational cost. To increase the depth of the network without increasing parameters is incorrect because depth and parameters are not directly related to receptive field size.Final Answer:
Option C -> Option CQuick Check:
Smaller fields capture local details. [OK]
Solution
Step 1: Identify convergence issues
Centroids initialized too close can cause slow convergence or getting stuck in local minima.Step 2: Eliminate other causes
Too many clusters can cause overfitting but not convergence issues. Data normalization affects distance calculation but not convergence. Euclidean distance is standard for K-Means.Final Answer:
Option A -> Option AQuick Check:
Close centroids = slow convergence [OK]
