Skip to content
Back to skills

Optional Batch Generators

ASecurity

"Router for imbalanced-learn balanced mini-batch helpers for Keras

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
toolsapibackend

Works with

  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill optional-batch-generators --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Optional Batch Generators?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Optional Batch Generators
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-optional-batch-generators/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-optional-batch-generators)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: optional-batch-generators
description: "Router for imbalanced-learn balanced mini-batch helpers for Keras
  and TensorFlow."
metadata:
  disco-role: operating
disable-model-invocation: true
license: MIT
---

# optional-batch-generators

Use this sub-skill when the task names balanced mini-batches, Keras, or
TensorFlow support in imbalanced-learn.

This sub-skill owns the optional generator helpers:

- `imblearn.tensorflow.balanced_batch_generator`
- `imblearn.keras.BalancedBatchGenerator`
- `imblearn.keras.balanced_batch_generator`

It is intentionally narrower than a deep-learning training skill. It covers the
balanced data iterator surface, not model architecture design, training loops,
or GPU acceleration strategy.

## What to do first

1. Check whether `tensorflow` or `keras` is actually importable.
2. Decide whether the user wants the TensorFlow iterator, the Keras `Sequence`,
   or both.
3. Confirm that the sampler exposes `sample_indices_`.
4. Keep the smoke tiny: generate a small batch, inspect the shapes, and stop.
5. Treat missing Keras/TensorFlow as an optional-capability skip, not a core
   package failure.

## Typical routing cues

- `balanced_batch_generator`
- `BalancedBatchGenerator`
- `keras`, `tensorflow`, `Sequence`, `fit`
- balanced mini-batches or class-balanced iterators

## When to read the bundled references

- `references/workflows.md` for import and backend decision flow.
- `references/api-reference.md` for the compact generator catalog.
- `references/troubleshooting.md` when backend imports or generator construction
  fail.

## Common choices

- Use `balanced_batch_generator` from `imblearn.tensorflow` when the workflow
  expects a simple generator/steps-per-epoch pair.
- Use `BalancedBatchGenerator` from `imblearn.keras` when the workflow wants a
  Keras `Sequence`-style object that can be passed to `fit`.
- Use the `sampler` parameter when the default `RandomUnderSampler` is not the
  desired balancing strategy.
- Use `keep_sparse=True` only when the downstream loop can consume sparse mini-
  batches.

## Native evidence to keep in mind

These repo tests are the most relevant later verification anchors for this
sub-skill:

- `imblearn/tensorflow/tests/test_generator.py::test_balanced_batch_generator`
- `imblearn/tensorflow/tests/test_generator.py::test_balanced_batch_generator_function_sparse`
- `imblearn/keras/tests/test_generator.py::test_balanced_batch_generator_class`
- `imblearn/keras/tests/test_generator.py::test_balanced_batch_generator_function`

## Package-specific cautions

- The generator helpers need a sampler with `sample_indices_`.
- `len(generator)` uses floor division by `batch_size`.
- `BalancedBatchGenerator` depends on the optional backend being importable at
  instantiation time.
- Keras and TensorFlow support is optional for the package as a whole, even
  though this sub-skill targets those APIs directly.

## Use the script

- `scripts/batch_generator_smoke.py` for a tiny optional-backend batch smoke.

Files in this skill

  • SKILL.md2.9 KB
  • references/api-reference.md1.2 KB
  • references/troubleshooting.md955 B
  • references/workflows.md1.2 KB
  • scripts/batch_generator_smoke.py1.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.