Class resampling changes the class distribution seen by a learning algorithm. In an imbalanced classification dataset, common classes can dominate training while rare but important classes contribute relatively little. For example, a transaction dataset containing 99,000 legitimate transactions and 1,000 fraudulent transactions allows a model that always predicts legitimate to achieve 99% accuracy. Resampling can make fraud examples more influential, but success must be measured through useful predictions rather than a balanced training dataset alone.
Random undersampling removes examples from majority classes. It reduces training time and storage requirements, but it can discard important variations and difficult boundary cases. Random oversampling repeats minority-class examples, preserving the original majority data while increasing training work and potentially encouraging memorization. Synthetic oversampling creates additional examples rather than simply duplicating existing ones. Hybrid strategies combine these approaches. A 50:50 distribution is not a universal goal; the sampling ratio should be selected using validation results and the operational costs of missed detections and false alarms.
For numeric tabular data, SMOTE generates synthetic minority examples by interpolating between neighboring minority observations. Its distance calculations require meaningful feature scales, so scaling parameters must be learned from training data only. Ordinary SMOTE is unsuitable for directly interpolating categorical identifiers or category codes. Mixed-type methods such as SMOTENC can handle categorical features, but generated records still require checks for valid combinations and business constraints. Synthetic samples can amplify mislabeled observations or bridge regions that should remain separate.
For text classification, engineers can oversample documents belonging to rare intent or moderation categories, or use class-aware sampling in the training data loader. Label-preserving paraphrasing can add variety, but replacements that change negation, sentiment, or intent invalidate labels. Applying SMOTE to vector representations does not create valid documents and may produce vectors that do not represent realistic language. Treat such feature-space techniques as experiments requiring validation, not as automatic substitutes for collecting representative text.
For image classification, a sampler can present rare-class images more often while applying appropriate random transformations during training. Cropping, rotation, and color changes must preserve the target label; rotating a digit or removing a small defect can change the task meaning. Augmentation is not inherently class balancing: applying identical augmentation policies and sampling frequencies to every class can leave the imbalance unchanged. Related images from the same patient, device, or capture sequence should remain in the same data partition.
Split data before resampling. Keep validation and test data representative of the intended deployment population, and resample only the training partition. Within cross-validation, fit preprocessing and resampling separately inside each training fold. Otherwise, duplicated examples or synthetic samples derived from held-out observations can leak information and inflate reported performance. Use stratified splits when appropriate, but honor temporal ordering and entity boundaries when those constraints better represent deployment.
In cloud workflows, managed processing jobs can profile class counts, validate labels, create training partitions, and execute resampling code. Training jobs can instead perform class-aware sampling dynamically, avoiding large stored copies of repeated text or images. Persist sampling ratios, random seeds, dataset versions, and transformation settings so that experiments can be reproduced. Distributed data loaders also need explicit sampler configuration so that sharding and repeated examples do not unintentionally distort the intended class mix.
Evaluate per-class precision and recall, macro F1, confusion matrices, and precision-recall curves rather than accuracy alone. Resampling changes the class prevalence observed during training, so predicted probabilities may need calibration using untouched, representative validation data. Class-weighted losses and decision-threshold adjustments are related alternatives, not resampling techniques; combining them requires testing to avoid overcompensation. Finally, balancing target labels does not automatically resolve demographic bias, missing population coverage, or poor labels. Audit performance across relevant groups as well as across classes.