# Dataset Imbalance Detector & Resampler

Detect class imbalance in CSV or JSON datasets, compare resampling strategies, and preview a balanced output dataset

> Canonical page: https://elysiatools.com/en/tools/dataset-imbalance-detector-resampler

- **Category:** Data Analysis

- **Keywords:** dataset imbalance, resampling, oversample, undersample, machine learning, class distribution

## Overview

Paste a CSV dataset or upload a CSV/JSON file, then specify the label column used for classification. The tool counts each class, measures the imbalance ratio, suggests whether oversampling or undersampling is safer, and generates a balanced dataset preview.

How to use it:
- Dataset Input: paste CSV text when exploring quickly
- Dataset File: upload CSV or JSON when working from a saved dataset
- Label Column: choose the target class column to profile
- Resampling Strategy: pick none, oversample, or undersample for the exported balanced dataset
- Export Format: preview the balanced result as JSON or CSV
- Preview Rows: limit how many balanced rows appear in the table

Notes:
- Oversample duplicates minority rows to match the majority count
- Undersample trims majority rows down to the minority count
- The report also compares both strategies so you can decide before exporting
- For production ML pipelines, the tool can help decide whether a more advanced method such as SMOTE is worth introducing later

## Inputs

- **Dataset Input** (textarea): id,label,score 1,yes,0.9 2,no,0.2
- **Dataset File** (file)
- **Label Column** (text): label
- **Resampling Strategy** (select)
- **Export Format** (select)
- **Preview Rows** (number)

## When to use

- When preparing training data for classification models to prevent algorithmic bias toward the majority class.
- When evaluating whether a dataset requires simple resampling techniques or more advanced methods like SMOTE.
- When you need a quick, code-free way to duplicate minority rows or trim majority rows in a CSV or JSON file.

## How it works

- Paste your raw CSV data or upload a saved CSV or JSON dataset file.
- Enter the exact name of your target classification column in the Label Column field.
- Select a resampling strategy (oversample or undersample) and choose your preferred export format.
- The tool calculates the class distribution, applies the chosen strategy, and outputs a balanced dataset preview.

## Use cases

- Balancing fraud detection datasets where fraudulent transactions make up less than 5% of the total data.
- Equalizing medical diagnosis records so a predictive model doesn't heavily favor negative test results.
- Normalizing customer churn data to ensure machine learning algorithms learn the characteristics of both retained and churned users equally.

## Frequently asked questions

### What is the difference between oversampling and undersampling?

Oversampling duplicates rows from the minority class to match the majority count, while undersampling randomly removes rows from the majority class to match the minority count.

### What file formats are supported for the dataset?

You can paste raw CSV text directly into the input field, or upload dataset files in CSV or JSON format.

### How do I know which resampling strategy to choose?

Undersampling is generally safer for very large datasets where dropping data won't cause severe information loss, while oversampling is better for small datasets where every data point is critical.

### Can I export the fully balanced dataset?

Yes, the tool generates a balanced dataset based on your chosen strategy, which you can preview and export in either JSON or CSV format.

### Does this tool apply SMOTE or synthetic data generation?

No, this tool uses exact row duplication for oversampling and random trimming for undersampling. It helps you baseline your data before deciding if complex synthetic methods are necessary.

## Related tools

- [Time Series Anomaly Detector](https://elysiatools.com/en/tools/time-series-anomaly-detector): Upload CSV or JSON time series data, detect anomalies with Z-Score and IQR methods, and return a chart-backed report
- [Dataset Quality Profiler](https://elysiatools.com/en/tools/dataset-quality-profiler): Profile CSV or JSON datasets for missing values, duplicate rows, format drift, type inference, and numeric outliers
- [Mock Data Prefix / Abbreviation Conflict Detector](https://elysiatools.com/en/tools/mock-data-naming-conflict-detector): Detect visually confusing field names and prefix collisions in CSV, JSON, or schema inputs, then suggest clearer renames
- [Time Series Forecast & Seasonality Analyzer](https://elysiatools.com/en/tools/time-series-forecast-seasonality-analyzer): Forecast future periods from CSV or JSON time-series data and inspect trend, seasonal, and residual decomposition in one report
- [Train/Test Split with Stratification](https://elysiatools.com/en/tools/train-test-split-with-stratification): Class-stratified train/validation/test split or stratified k-fold for CSV/JSON datasets — seeded, reproducible, with distribution reports, leakage checks, SMOTE preview and CSV export.
- [JSON Path Visualizer](https://elysiatools.com/en/tools/json-path-visualizer): Visualize JSON or JSONL as an expandable tree and copy JSONPath expressions for every node
- [CSV to Database Migration Planner](https://elysiatools.com/en/tools/csv-to-database-migration-planner): Infer a relational schema from CSV data and generate create-table plus ALTER migration plans for PostgreSQL, MySQL, SQLite, or SQL Server
- [Structured Log Analyzer](https://elysiatools.com/en/tools/structured-log-analyzer): Detect common log formats, extract core fields, infer field types, and export parsed logs as JSON, CSV, or SQL inserts

## Samples

- [CSV Samples](https://elysiatools.com/en/samples/csv-samples): Sample CSV files with various data types, sizes, and complexity levels
- [Python Samples](https://elysiatools.com/en/samples/python): Essential Python code examples and Hello World demonstrations
- [Distributed Tracing Samples](https://elysiatools.com/en/samples/distributed-tracing-samples): Comprehensive distributed tracing examples using Jaeger, OpenTelemetry, and other modern observability tools for microservices architecture
- [JWT Samples](https://elysiatools.com/en/samples/jwt-samples): Comprehensive JWT examples from basic token structure to advanced security implementations
