AWS Certified Machine Learning Engineer - Associate (MLA-C02) free question 4 / 10 · Domain 2: ML Model and Foundation Model (FM) Development
A team trains a SageMaker AI k-NN model on vectors with 4,096 features. The model is large in memory, inference is slow, and the data is sparse in that many dimensions. Which part of k-NN training addresses these problems?
- Dimension reduction, which decreases the feature dimension to save memory
- Index building, which creates the lookups of distances between stored points
- Sampling, which reduces the number of rows so that the dataset fits into memory
- Increasing k, so that more neighbors vote on the predicted label for a sample
Show the answer and explanation
Answer: A
Why this is correct
Training with the k-NN algorithm has three steps: sampling, dimension reduction, and index building. Dimension reduction decreases the feature dimension of the data to reduce the footprint of the k-NN model in memory and the inference latency. The page offers two methods, random projection and the fast Johnson-Lindenstrauss transform, and says you typically use dimension reduction for high-dimensional (d > 1000) datasets to avoid the curse of dimensionality that troubles the statistical analysis of data that becomes sparse as dimensionality increases.
Why the other options are wrong
"Sampling, which reduces the number of rows so that the dataset fits into memory" … Sampling reduces the size of the initial dataset so that it fits into memory. It shrinks the number of observations, whereas the problem here is the number of features.
"Index building, which creates the lookups of distances between stored points" … Index building is the main objective of k-NN training and enables efficient lookups of the k nearest points. It does not decrease the feature dimension of the data.
"Increasing k, so that more neighbors vote on the predicted label for a sample" … Changing k alters how many neighbors contribute to a prediction. It does not shrink the model footprint or address the curse of dimensionality.
Key points
For classification, k-NN queries the k points closest to the sample point and returns the most frequently used label among them. For regression, it returns the average of the feature values of the k closest points. The index it builds is what makes those lookups efficient.