# ufoym/imbalanced-dataset-sampler

A (PyTorch) imbalanced dataset sampler for oversampling low frequent classes and undersampling high frequent ones.

Repository: https://github.com/ufoym/imbalanced-dataset-sampler
Canonical: https://ross.abutalabs.com/products/imbalanced-dataset-sampler
Language: Python
License: MIT
License Family: permissive
Topics: pytorch, imbalanced-data, image-classification, data-sampling
Last push: 2026-07-06T20:24:50+00:00

## Health v2 (maintenance only)
Score: 64/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 91, release rhythm 8, longevity 100
- inputs: {"age_days": 3019, "days_push": 58, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2326, forks 266 (observed 2026-08-28T04:06:37.465536+00:00)

## What it is
A PyTorch dataset sampler (ImbalancedDatasetSampler, pip package torchsampler) that rebalances class distributions during training by oversampling rare classes and undersampling frequent ones. It estimates sampling weights automatically and plugs directly into DataLoader.

## Use cases
- handle imbalanced datasets in pytorch
- oversample minority classes during training
- prevent model bias toward majority class
- balance class distribution in dataloader
- train classifier on rare disease images

## When to choose
- you train PyTorch models on class-imbalanced data
- you want automatic sampling weights without building a new balanced dataset

## When to avoid
- you use TensorFlow or non-PyTorch frameworks
- you need advanced resampling like SMOTE

## Facets
- artifact type: library
- maturity: stable
- function: machine-learning, data-science
- domain: machine-learning, deep-learning
- platform: python
- tags: pytorch, sampler, imbalanced-data, oversampling, undersampling

## Member repositories
- ufoym/imbalanced-dataset-sampler (main) score 64

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:37.465536+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:38:15.930244+00:00, confidence not recorded.
  - readme: https://github.com/ufoym/imbalanced-dataset-sampler (fetched 2026-08-28T04:06:37.465536+00:00, sha 05e6c6e05b7a)
- Data as of 2026-08-30T08:39:29.467469+00:00.
