AGENT SKILL

sampling-algorithms

Router for imbalanced-learn over-sampling, under-sampling, combine samplers, and custom resampling primitives.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
sampling-algorithms
license
MIT
metadata
{ "disco-role": "operating" }
description
Router for imbalanced-learn over-sampling, under-sampling, combine samplers, and custom resampling primitives.
disable-model-invocation
true

02 资源文件 5

03 SKILL.md 正文

sampling-algorithms

Use this sub-skill when the task is about choosing, configuring, or debugging an imbalanced-learn sampler.

This sub-skill owns the package families that directly change class counts or sample composition:

  • over-sampling: RandomOverSampler, ADASYN, SMOTE, SMOTENC, SMOTEN, BorderlineSMOTE, KMeansSMOTE, SVMSMOTE
  • under-sampling: RandomUnderSampler, TomekLinks, EditedNearestNeighbours, RepeatedEditedNearestNeighbours, AllKNN, OneSidedSelection, CondensedNearestNeighbour, NeighbourhoodCleaningRule, NearMiss, ClusterCentroids, InstanceHardnessThreshold
  • combine samplers: SMOTEENN, SMOTETomek
  • custom resampling: FunctionSampler

What to do first

  1. Decide whether the request is about increasing minority support, reducing majority support, cleaning borderline samples, or writing a custom sampler.
  2. Identify the input shape: dense NumPy array, sparse matrix, pandas DataFrame, mixed object array, or all-categorical data.
  3. Check whether the workflow needs categorical handling, neighbor-based synthesis, or a simple bootstrap-style resampler.
  4. Fit only on the training branch; do not resample the full dataset before a split.
  5. Verify the result with a tiny count check before moving on.

Typical routing cues

  • sampling_strategy
  • fit_resample
  • random_state, replacement, shrinkage
  • k_neighbors, m_neighbors, n_neighbors
  • SMOTE, ADASYN, NearMiss, TomekLinks, SMOTEENN
  • FunctionSampler
  • pandas or sparse input support during resampling
  • categorical features or all-categorical samples

When to read the bundled references

  • references/workflows.md for the decision tree from task shape to sampler family.
  • references/api-reference.md for the compact public sampler catalog and key signatures.
  • references/troubleshooting.md when neighbor counts, dtype errors, sparse output, or categorical feature handling fail.

Common choices

  • Use RandomOverSampler when the request is about a simple, duplicate-based bootstrap.
  • Use SMOTE or one of its variants when the request needs synthetic minority samples.
  • Use SMOTENC for mixed numeric/categorical features.
  • Use SMOTEN when all features are categorical.
  • Use RandomUnderSampler when the request needs a fast majority reduction.
  • Use TomekLinks, EditedNearestNeighbours, RepeatedEditedNearestNeighbours, AllKNN, or NeighbourhoodCleaningRule when the request is about cleaning noisy or borderline observations.
  • Use ClusterCentroids when the task wants prototype generation rather than simply selecting existing samples.
  • Use SMOTEENN or SMOTETomek when the task wants a packaged over/under combination.
  • Use FunctionSampler when the user already knows the exact custom logic and only needs a thin sampler wrapper.

Native evidence to keep in mind

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

  • imblearn/over_sampling/tests/test_random_over_sampler.py::test_ros_fit_resample
  • imblearn/over_sampling/_smote/tests/test_smote.py::test_sample_regular
  • imblearn/over_sampling/_smote/tests/test_smote_nc.py::test_smotenc_pandas
  • imblearn/under_sampling/_prototype_selection/tests/test_random_under_sampler.py::test_rus_fit_resample
  • imblearn/under_sampling/_prototype_selection/tests/test_tomek_links.py::test_tl_fit_resample
  • imblearn/combine/tests/test_smote_enn.py::test_sample_regular
  • imblearn/tests/test_base.py::test_function_sampler_func

Package-specific cautions

  • SMOTE-family methods need a sensible neighbor configuration and enough minority samples.
  • SMOTENC needs a categorical feature specification that matches the input layout.
  • SMOTEN is for categorical-only data, not mixed numeric/categorical data.
  • RandomOverSampler(shrinkage=...) is numeric-data only.
  • ClusterCentroids may densify or become inefficient on sparse data.
  • FunctionSampler should remain small and explicit; it is not a replacement for a full pipeline.

Use the scripts

  • scripts/sampler_smoke.py for a tiny representative resampling smoke.
  • scripts/sampling_strategy_demo.py for small examples of dict and callable sampling strategies.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351