Calculate the imbalance ratio between majority and minority classes in a dataset.
The class imbalance ratio divides the majority class count by the minority class count, giving a single number that summarizes how skewed a classification dataset is. A ratio below 3:1 is generally considered mild and often trainable without special handling, while ratios above 10:1 typically require resampling, class weighting, or specialized loss functions (e.g. focal loss) to prevent the model from simply predicting the majority class.
imbalance_ratio = majority_class_count / minority_class_count
Most practitioners start applying mitigation techniques around a 10:1 ratio, though the right threshold depends on how costly minority-class errors are for your application (e.g. fraud or disease detection tolerate less imbalance).
No — at high imbalance, a model predicting only the majority class can achieve high accuracy while being useless; use precision, recall, F1, or AUPRC instead.
Common approaches include oversampling the minority class (SMOTE), undersampling the majority class, class-weighted loss functions, or reframing the problem as anomaly detection.