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
- 参考文档references/api-reference.md3.8 KB
- 参考文档references/troubleshooting.md1.7 KB
- 参考文档references/workflows.md2.6 KB
- 脚本scripts/sampler_smoke.py1.9 KB
- 脚本scripts/sampling_strategy_demo.py971 B
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
- Decide whether the request is about increasing minority support, reducing majority support, cleaning borderline samples, or writing a custom sampler.
- Identify the input shape: dense NumPy array, sparse matrix, pandas DataFrame, mixed object array, or all-categorical data.
- Check whether the workflow needs categorical handling, neighbor-based synthesis, or a simple bootstrap-style resampler.
- Fit only on the training branch; do not resample the full dataset before a split.
- Verify the result with a tiny count check before moving on.
Typical routing cues
sampling_strategyfit_resamplerandom_state,replacement,shrinkagek_neighbors,m_neighbors,n_neighborsSMOTE,ADASYN,NearMiss,TomekLinks,SMOTEENNFunctionSampler- pandas or sparse input support during resampling
- categorical features or all-categorical samples
When to read the bundled references
references/workflows.mdfor the decision tree from task shape to sampler family.references/api-reference.mdfor the compact public sampler catalog and key signatures.references/troubleshooting.mdwhen neighbor counts, dtype errors, sparse output, or categorical feature handling fail.
Common choices
- Use
RandomOverSamplerwhen the request is about a simple, duplicate-based bootstrap. - Use
SMOTEor one of its variants when the request needs synthetic minority samples. - Use
SMOTENCfor mixed numeric/categorical features. - Use
SMOTENwhen all features are categorical. - Use
RandomUnderSamplerwhen the request needs a fast majority reduction. - Use
TomekLinks,EditedNearestNeighbours,RepeatedEditedNearestNeighbours,AllKNN, orNeighbourhoodCleaningRulewhen the request is about cleaning noisy or borderline observations. - Use
ClusterCentroidswhen the task wants prototype generation rather than simply selecting existing samples. - Use
SMOTEENNorSMOTETomekwhen the task wants a packaged over/under combination. - Use
FunctionSamplerwhen 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_resampleimblearn/over_sampling/_smote/tests/test_smote.py::test_sample_regularimblearn/over_sampling/_smote/tests/test_smote_nc.py::test_smotenc_pandasimblearn/under_sampling/_prototype_selection/tests/test_random_under_sampler.py::test_rus_fit_resampleimblearn/under_sampling/_prototype_selection/tests/test_tomek_links.py::test_tl_fit_resampleimblearn/combine/tests/test_smote_enn.py::test_sample_regularimblearn/tests/test_base.py::test_function_sampler_func
Package-specific cautions
SMOTE-family methods need a sensible neighbor configuration and enough minority samples.SMOTENCneeds a categorical feature specification that matches the input layout.SMOTENis for categorical-only data, not mixed numeric/categorical data.RandomOverSampler(shrinkage=...)is numeric-data only.ClusterCentroidsmay densify or become inefficient on sparse data.FunctionSamplershould remain small and explicit; it is not a replacement for a full pipeline.
Use the scripts
scripts/sampler_smoke.pyfor a tiny representative resampling smoke.scripts/sampling_strategy_demo.pyfor small examples of dict and callable sampling strategies.
04 同仓库更多 Skills
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.
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.
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.
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.
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.
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).