Based on the MLS-C01 exam guideReport an error
Building a good model requires enough balanced data, but reality is different. Rare disease diagnosis data has extremely few positive samples, fraudulent transactions are 0.1% of the total, and some image classes have only a handful of pictures. Left as is, the model gets the majority class right and misses the minority class that actually matters.
MLS-C01 asks not about code implementation but "which technique fits which situation."
| Situation | First response | Second response |
|---|---|---|
| The total amount of data is small | Transfer learning, data augmentation | Supplement with synthetic data |
| Only a specific class is scarce | Oversampling/SMOTE, class weights | Threshold adjustment |
| Real data cannot be used (privacy) | Synthetic tabular data | Anonymization, differential privacy |
| There are no examples of rare or dangerous situations | Simulation | Domain-rule-based generation |
| Labels are scarce | Active learning, weak supervision | Semi-supervised learning |
Data augmentation is a technique that creates new training samples by transforming existing data. Without collecting new data, it increases the diversity and quantity of the dataset, improving generalization and reducing overfitting.
The core principle of augmentation is "a transformation that does not change the label." A cat photo flipped horizontally is still a cat. In other words, you should apply only transformations that preserve the correct answer (the label) while diversifying just the input. Through this, the model learns invariance: "the essence is the same even when position, angle, or brightness differ."
Images are the area where augmentation is most active.
| Transformation family | Examples | Invariance the model gains |
|---|---|---|
| Geometric transforms | Horizontal/vertical flip, rotation, translation, scaling, crop | Changes in position, angle, and size |
| Color/brightness transforms | Brightness, contrast, saturation adjustment, color jitter | Differences in lighting and cameras |
| Noise/masking | Gaussian noise, region occlusion (Cutout) | Partial occlusion, degraded quality |
| Mixing | Blending two images (Mixup/CutMix) | Smoother decision boundaries |
# Image augmentation (conceptual example - torchvision transforms)
from torchvision import transforms
augment = transforms.Compose([
transforms.RandomHorizontalFlip(p=0.5), # horizontal flip
transforms.RandomRotation(degrees=15), # rotate by ±15 degrees
transforms.ColorJitter(brightness=0.2, # brightness/contrast changes
contrast=0.2),
transforms.RandomResizedCrop(224), # random crop, then resize
])⚠️ Pitfall: Indiscriminate augmentation ruins labels. In digit recognition, rotating a "6" by 180 degrees makes it a "9," breaking the label. In medical imaging, a horizontal flip swaps left and right organs and damages the diagnostic meaning. Augmentation must be applied only within the range that preserves domain meaning.
⚠️ Pitfall: In text augmentation, touching a negation word ("not," "no") flips the label to the opposite. Applying heavy random deletion to sentiment analysis data actually lowers performance.
If augmentation is "transforming existing data," synthesis is closer to generating entirely new virtual data. It is used when real data is extremely scarce or cannot be used because of privacy.
| Method | Description | Typical use |
|---|---|---|
| GAN | A generator and a discriminator compete to produce realistic data | Image generation, supplementing rare cases |
| Simulation | Creates situations with a physics or rule engine | Dangerous scenarios for autonomous driving, robotics |
| Synthetic tabular data | Mimics statistical distributions to create a fake table with no personal information | Privacy protection, external sharing |
Synthetic data is powerful, but it carries the risk of a "distribution gap." If synthetic data cannot perfectly reproduce the real data distribution, a model trained on it performs worse in the real world. So use synthetic data to supplement real data, and always validate with real data.
Class imbalance is an easily confusing topic on the ML exam. In fraud detection with positive:negative = 1:999, a model that answers "all negative" gets 99.9% accuracy but is a useless model that catches no fraud at all.
The response strategy has three broad layers.
[Data layer] Oversampling / Undersampling / SMOTE
▼
[Algorithm layer] Class weights / Decision threshold adjustment / Cost-sensitive learning
▼
[Evaluation layer] No accuracy → recall · F1 · PR-AUC
| Technique | Behavior | Advantage | Risk |
|---|---|---|---|
| Oversampling (duplication) | Increases the minority class by duplicating it | No information loss | Repeating the same points → overfitting |
| Undersampling | Reduces the majority class to balance | Faster training | Loss of majority class information |
| SMOTE | Generates new points by interpolating between a minority sample and its nearest neighbors | Secures diversity, mitigates overfitting | Wrong synthesis in boundary and noisy regions |
# Synthetic oversampling of the minority class with SMOTE (conceptual example - imbalanced-learn)
from imblearn.over_sampling import SMOTE
smote = SMOTE(random_state=42)
X_balanced, y_balanced = smote.fit_resample(X_train, y_train)
# Synthetic samples interpolated between minority-class samples are added so the class ratio is balancedUnlike simple duplication (which risks overfitting from repeats), SMOTE creates new points on the line connecting an existing minority sample and its nearest neighbors. As a result, the model learns a more generalized decision boundary. However, with noisy data or ambiguous class boundaries it can create wrong synthetic samples, so caution is needed.
Resampling must be applied only to the training set. If you balance the validation and test sets too, they differ from the real operating distribution and the performance is inflated. Even when using cross-validation, run SMOTE only on the training portion of each fold.
scale_pos_weight is the typical example.On imbalanced data, accuracy gives false reassurance. A 99.9% accuracy on 1:999 data is virtually meaningless. Instead, you must evaluate minority-class performance properly with precision, recall, F1, PR-AUC, and ROC-AUC. In problems where the minority class matters, such as fraud or disease, recall and PR-AUC are the key.
Even the same augmentation changes in character depending on when it is applied.
| Approach | When it is created | Advantage | Disadvantage |
|---|---|---|---|
| Pre-generated (offline) | Created and stored in advance before training | No CPU load during training, easy to reproduce | More storage, diversity is fixed |
| Real-time (on-the-fly) | Random transformation each time a batch is built | Different transformations every epoch → greater diversity | The data loader can become a bottleneck |
You should not be reassured just by a statement like "we lacked training data, so we expanded it 10x with augmentation." Augmentation cannot create new information. If the original is 100 images, however much you expand it, you cannot get more diversity than those 100 images contain. The fundamental solutions are data collection or transfer learning.
Separate from imbalance, there are also situations where "the labels themselves are scarce."
All four of these attack the same goal, "reduce the number of labels humans must attach," from different directions. Transfer learning reduces the problem on the model side, augmentation on the input side, active learning on the selection side, and weak supervision on the label-generation side. When "reducing labeling cost" appears on the exam, the answer is often one of these four.
scale_pos_weight.🎯 Scenario: "Credit card fraud detection data is extremely imbalanced at 0.2% positive. The model almost never catches fraud." → (1) Correct the imbalance with oversampling such as SMOTE or with class weights, (2) evaluate with recall and PR-AUC instead of accuracy, and (3) adjust the decision threshold toward fraud detection.
Tomorrow we cover how to feed prepared data efficiently into training (Pipe/File mode, FSx for Lustre, sharding).
Click a choice to reveal the answer and explanation.
Question 1
On extremely imbalanced fraud detection data with 0.2% positives, which is the least appropriate metric for evaluating model performance?
Question 2
What is the key characteristic that distinguishes SMOTE from simple duplication (duplicate oversampling)?
Question 3
Which is the most correct principle that must be followed when applying data augmentation?
Question 4
When real data is extremely scarce or cannot be used directly because of privacy constraints, which approach for generating new virtual data is the most appropriate?
Question 5
Before putting a model trained on synthetic data into production, which is the most important risk to consider?