Rebalance an imbalanced CSV label column

Paste labeled CSV, pick the label column and a strategy, and over- or under-sample whole rows toward your target class ratio — reproducibly, with a fixed seed. Nothing is uploaded.

Try:
Rebalanced CSV

About this tool

Class Rebalancer evens out an imbalanced label column in a CSV by resampling whole rows — randomly duplicating rows from the smaller class(es) to bring them up (over-sampling) and/or randomly dropping rows from the larger class(es) to bring them down (under-sampling), toward a target class ratio you choose.

Pick the label column and a strategy, and every class moves toward the same size (or a ratio you set). The picks are driven by a fixed seed, so the same input and seed always produce the same output — change the seed for a different draw. Everything runs locally in your browser; no rows are uploaded, and no synthetic rows are invented (this is random resampling, not SMOTE).

Worked example

CSV — one spam row and three ham rows (a 1:3 imbalance):

text,label
buy now,spam
hello,ham
hi there,ham
see you,ham

With label column label, strategy oversample, and target ratio 1.0, the minority spam class is duplicated up to the majority size (3), keeping the originals first and appending the duplicates:

text,label
buy now,spam
hello,ham
hi there,ham
see you,ham
buy now,spam
buy now,spam

Switch Output to the before/after summary to get a JSON count report instead of the CSV:

{
  "classes": [
    {"label": "spam", "before": 1, "after": 3},
    {"label": "ham", "before": 3, "after": 3}
  ],
  "strategy": "oversample",
  "target_ratio": 1,
  "total_before": 4,
  "total_after": 6
}

Limits & edge cases

FAQ

What is class imbalance and why rebalance?

Class imbalance is when one label dominates your dataset — say 95% "not fraud" and 5% "fraud". Many models learn to just predict the majority and still look accurate, while missing the class you care about. Rebalancing evens the class counts so the training signal is more even; over-sampling repeats minority rows, under-sampling drops majority rows.

Does this create synthetic rows like SMOTE?

No. This tool only copies or removes whole existing rows — every output row is an exact row from your input. It does not interpolate or generate new synthetic samples between points the way SMOTE does, so it never invents feature values that weren't in your data.

Why is there a seed, and is the output reproducible?

The seed drives the reproducible pseudo-random picks for which rows to duplicate or drop (and the optional shuffle). The same input and seed always give the same output, so your rebalanced set is fully reproducible; change the seed to get a different random draw.

What's the difference between oversample, undersample, and combine?

Oversample duplicates minority-class rows until they reach the target ratio, keeping every majority row. Undersample drops majority-class rows down to the target, keeping every minority row. Combine does both, moving every class to a common size. Oversample keeps all your data but repeats some; undersample throws data away but adds no duplicates.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool class-rebalancer "text,label
buy now,spam
hello,ham
hi there,ham
see you,ham"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/class-rebalancer/?data=text%2Clabel%0Abuy%20now%2Cspam%0Ahello%2Cham%0Ahi%20there%2Cham%0Asee%20you%2Cham&label_column=label&strategy=auto&target_ratio=1&header=true&shuffle=true&seed=42&output=csv

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.