Imbalanced Dataset Generator
A model that flags nothing as fraud is 99% accurate on data with 1% fraud. That single fact is behind most misreported classification results, and it is far more convincing as a number you generated than as a warning you read. This builds a two-class dataset at whatever imbalance you choose and states the majority-class baseline outright, because that is the score any real model has to beat.
What this generator does
Builds a single feature that separates the classes by an adjustable amount, then labels rows to hit the ratio you asked for. The majority-class baseline is computed and shown prominently, since a model that cannot beat it has learned nothing at all.
How to use this tool
- Set how many rows and how rare the minority class should be.
- Adjust the separation to make the classes easier or harder to tell apart.
- Generate, and note the majority baseline before doing anything else.
- Copy the CSV and check your model beats that number.
Understanding the controls
- Minority class share
- Anything below 50%. At 1% the majority baseline is 99%, which is the case worth seeing.
- Class separation
- How distinguishable the classes are on the feature. At zero they are indistinguishable and no model can do better than the baseline, which is itself a useful test.
- How many rows
- Between 20 and 1,000. At extreme ratios a small dataset may hold only a handful of positives, which is realistic.
- Seed
- Reproduces the same dataset while the generator is unchanged, so two approaches can be compared fairly.
Worked examples
- 20 rows, 5% positive, seeded "demo"
- 1 positive against 19 negatives — a ratio of about 1 to 19. Always guessing the majority class scores 95.0% accuracy while finding none of the positives at all, which is the number any real model has to beat before it has learned anything.
Common use cases
- Testing a classifier against a realistic imbalance rather than a tidy 50/50
- Demonstrating why accuracy is a misleading headline metric
- Producing data to compare precision, recall and F1 against accuracy
- Checking whether resampling or class weights actually help
- Teaching the accuracy trap with a number rather than a caution
How this generator works
Positives are drawn around a separated mean and negatives around zero, with the counts fixed to your requested ratio rather than sampled — so the imbalance is exact. The baseline is the larger class divided by the total.
Randomness and fairness
The feature values are random; the class ratio is not, being fixed by construction. Seeded runs are reproducible and therefore explicitly not cryptographically secure; unseeded ones use the browser's cryptographically secure generator.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- A single feature, which makes the problem far easier than a real one.
- It generates the imbalance but does not address it — resampling and class weighting are yours to apply.
- Real rare-class problems usually also have label noise, which is not modelled here.
- Nothing persists between visits, so seed anything you want to compare against later.
Privacy and your data
The dataset is built in your browser and stays there. No seed and no row is uploaded or stored between visits; what is measured is that a dataset was made and how many rows were asked for.
Frequently asked questions
- Why does 95% accuracy mean nothing here?
- Because a model that never predicts the minority class also scores 95% on data that's 95% one class — accuracy alone can't distinguish a model that learned something from one that learned nothing at all. Precision, recall and F1 on the minority class are what actually show whether a model beats the naive majority-guess baseline this page states outright.
- What does the separation control actually change?
- It sets how far apart the two classes' feature distributions are centred — at zero they fully overlap and no model can beat the majority baseline, since the feature carries no real signal. Raising separation makes the classes genuinely distinguishable, which is what lets you test whether a classifier can exploit a real (if rare) signal rather than just parroting the majority class.
Related generators
- Regression Dataset GeneratorData built from a slope and intercept you choose, with the line fitted back out of it so you can see how close estimation gets.
- Missing Data GeneratorDatasets with gaps under all three mechanisms — completely at random, dependent on a column you can see, and dependent on the missing value itself.
- Clustered Dataset GeneratorPoints grouped around known centres with the true group recorded, so you can check what a clustering algorithm actually recovered.
- Correlated Dataset GeneratorTwo numeric columns with a correlation you choose, plus optional blanks, duplicate rows and outliers — for testing charts, cleaning pipelines and statistics teaching.
- Statistical Power CalculatorWorks out the chance a test would detect a real effect of a given size, and how many people it would take to reach the usual eighty per cent.