About this tool
Check label distribution in a classification dataset: imbalance ratio, entropy, balanced class weights and resampling counts.
The Dataset Class Balance Checker reads a list of classification labels and reports the imbalance ratio, normalised Shannon entropy, Gini impurity and the majority-class baseline accuracy for the dataset. It also prints scikit-learn's balanced class weights, n_samples / (n_classes x n_class_rows), and the row counts you would end up with after oversampling or undersampling. Labels are parsed in your browser from plain lines, a CSV column or a JSONL property, so no data leaves the page.
Open Dataset Class Balance Checker on AltFTool — it loads instantly in your browser.
Paste your code or data sample into the workspace.
Pick the format, conversion, or analysis you need.
Copy the polished result straight back into your project.
Parsing and maths happen client-side, so private datasets never leave the browser.
Copy the balanced class weights straight into class_weight or a loss function.
Warns about rare classes, unusable cross-validation splits and misleading accuracy.
An imbalance ratio at or below 1.5:1 behaves like a balanced dataset, and up to about 3:1 rarely needs special handling. Beyond roughly 10:1, plain accuracy stops being informative and you should switch to macro-F1, balanced accuracy or PR-AUC and consider resampling or class weights.
scikit-learn's class_weight="balanced" sets each class weight to n_samples / (n_classes x n_rows_in_class). With 100 rows split 90/10 across two classes, the majority weight is 100 / (2 x 90) = 0.56 and the minority weight is 100 / (2 x 10) = 5.0.
At minimum, each class needs as many rows as your cross-validation fold count, because StratifiedKFold cannot split a class with fewer members than n_splits (the default is 5). In practice fewer than about 10 rows in a class makes per-class precision and recall too noisy to compare between runs.
No. Resample only the training split and leave validation and test at the real-world distribution, otherwise your reported metrics describe a dataset that does not exist in production. Class weights are often preferred over oversampling because they leave the data untouched.