balance dataset
- Dominant language
- Python
- Stars
- 5.7k
- Forks
- 1.1k
- Avg merge
- 12d 2h
- Merged PRs (30d)
- 1
Description
Balancing a dataset between target categories is a common best practice.
Currently, my approach follows that of the data sampling documentation for over/under-sampling: select rows, send the over-represented category (matching data) to a data sampler, then concatenate the downsampled data with the under-represented category, like this:

If I want the fixed sample size of the downsampled data to match the size of the unmatched data, I have to hard-code the fixed sample size. This works, but it gets repetitive whenever I change anything upstream (e.g., filter the data differently using select rows).
I have two proposed solutions:
1. It would be nice to connect configuration parameters to another component, although I don't see this done anywhere in Orange, so this might be asking a lot. For example, I could connect the "fixed sample size" parameter in the data sampler to the size of the unmatched data from the select rows component.
2. Add a "balance data" option to the data sampler. Options could be to downsample or upsample (sample with replacement) to one category size or some other fixed size.
Thanks!
Contributor guide
Research direction
Start with the data sampling documentation and inspect the Data Sampler and Select Rows components described in the issue. Compare the proposed parameter connection and balance-data approaches, then define the supported balancing behavior and its completion criteria before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100