Practice
import numpy as np
from sklearn.cluster import KMeans
X = np.array([[1, 2], [1, 4], [1, 0], [4, 2], [4, 4], [4, 0]])
kmeans = KMeans(n_clusters=2, random_state=0).fit(X)
centroids = kmeans.cluster_centers_Solution
Step 1: Analyze the code
The code uses KMeans with n_clusters=2 on a dataset with 2 features.Step 2: Determine the output shape
The centroids will have a shape of (2, 2) because there are 2 clusters and each centroid has 2 features.Final Answer:
Option C -> Option CQuick Check:
Centroids shape = (clusters, features) [OK]
Solution
Step 1: Identify symptoms of overfitting.
Overfitting occurs when a model learns noise instead of the signal.Step 2: Determine the cause related to model complexity.
Too many parameters can lead to overfitting by capturing noise.Final Answer:
Option B -> Option BQuick Check:
Overfitting often means too complex a model. [OK]
Solution
Step 1: Consider the nature of gradual shifts.
Gradual shifts require a system that can adapt over time without waiting for performance to drop significantly.Step 2: Evaluate the options.
Use periodic retraining with a fixed schedule regardless of data shifts. is incorrect because a fixed schedule may not align with shifts. Use continual learning without any additional mechanisms. is incorrect because continual learning alone may not handle shifts effectively. Use periodic retraining only when performance drops significantly. is incorrect because waiting for performance drops can lead to suboptimal results.Final Answer:
Option C -> Option CQuick Check:
Adapt to shifts with detection. [OK]
Solution
Step 1: Consider interpretability needs
Small kernels with more layers help capture local patterns, which are crucial for interpretability in medical imaging.Step 2: Eliminate wrong options
Use very deep networks to capture complex patterns is incorrect because very deep networks can be less interpretable. Use shallow networks with large kernels to capture global patterns is incorrect as large kernels reduce local detail capture. Use networks with attention mechanisms to highlight important regions is incorrect because attention mechanisms, while useful, are not leveraging CNN's inductive bias.Final Answer:
Option A -> Option AQuick Check:
Small kernels capture local details, aiding interpretability. [OK]
Solution
Step 1: Address class imbalance and overfitting
Class weights help balance the dataset, and early stopping prevents overfitting by halting training when validation performance stops improving.Step 2: Eliminate wrong options
Use SMOTE to oversample the minority class and increase model complexity. increases complexity, risking overfitting, Downsample the majority class and increase the learning rate. may lead to instability, and Use a simpler model with no regularization. lacks regularization, increasing overfitting risk.Final Answer:
Option C -> Option CQuick Check:
Class weights + early stopping = balanced, robust model [OK]
