DEA-C01 Question 392
Single answerYou are working on a machine learning pipeline using Amazon SageMaker, and your dataset contains 1 billion rows. To speed up the training process and reduce resource costs, you decide to sample the dataset. Which of the following sampling techniques would be most appropriate if you want to ensure that the representation of different classes in the dataset is preserved?
- A
Random sampling
- B
Stratified sampling
- C
Systematic sampling
- D
Cluster sampling
Show answer and explanation
Correct answer: B
Explanation
Stratified sampling is the best choice when you want to ensure that the sampled dataset maintains the same class distribution as the original dataset. This is particularly important in machine learning tasks where class imbalance can significantly impact the model's performance.
- A. Incorrect.
Random sampling selects rows randomly without considering the distribution of classes. This can lead to an imbalanced dataset, especially if the classes are unevenly distributed.
- B. Correct.
Stratified sampling ensures that the representation of each class in the dataset is preserved by sampling proportionally from each class. This is ideal for machine learning tasks where class balance is critical.
- C. Incorrect.
Systematic sampling selects rows at regular intervals, which does not account for class distribution and may lead to biased samples.
- D. Incorrect.
Cluster sampling divides the dataset into clusters and randomly selects entire clusters for sampling. This method does not guarantee the preservation of class distribution.