AGENT SKILL

fairlearn

Use Fairlearn to assess group fairness, compute disparity metrics, visualize subgroup performance, and mitigate unfairness with preprocessing, reductions, postprocessing, or adversarial learning.

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

01 前言 Front Matter

name
fairlearn
license
MIT
metadata
{ "disco-role": "operating" }
description
Use Fairlearn to assess group fairness, compute disparity metrics, visualize subgroup performance, and mitigate unfairness with preprocessing, reductions, postprocessing, or adversarial learning.
disable-model-invocation
true

02 资源文件 6

03 SKILL.md 正文

Fairlearn

Use this repo skill when a task names fairlearn, asks for the Fairlearn Python package, or uses Fairlearn vocabulary such as MetricFrame, sensitive_features, demographic parity, equalized odds, CorrelationRemover, ExponentiatedGradient, GridSearch, ThresholdOptimizer, AdversarialFairnessClassifier, or Fairlearn dataset fetchers.

Fairlearn is API-first. This checkout does not define a Fairlearn-specific command-line interface, so route future agents to Python APIs, bundled references, and the smoke scripts in this skill.

Install and quick verification

For normal package use:

python -m pip install fairlearn

Add optional plotting and adversarial-learning dependencies only when the workflow needs them:

python -m pip install matplotlib        # group plots and threshold-optimizer plots
python -m pip install torch             # PyTorch adversarial backend
# TensorFlow is an alternative adversarial backend, but was not verified in this skill run.

From this skill directory, run the bundled root check when you need a safe import and optional-backend smoke test:

python scripts/check_install.py --include-optional

Read references/installation.md for version and optional dependency details, references/troubleshooting.md for cross-cutting failures, and references/repo-provenance.md before deciding whether this skill is stale for a newer Fairlearn checkout.

Route map

Task signal Read this sub-skill Why
Group metrics, MetricFrame, selection_rate, demographic parity/equalized odds metrics, intersections, bootstrapped confidence intervals, model comparison plots, ROC-by-group plots sub-skills/assessment/SKILL.md Assessment owns Fairlearn metrics, grouped outputs, CIs, and plotting helpers.
Remove linear correlation with sensitive columns, fair representation learning, CorrelationRemover, PrototypeRepresentationLearner, preprocessing before a downstream estimator sub-skills/preprocessing/SKILL.md Preprocessing owns transformations applied before model training.
Fairness-constrained training with sklearn-compatible estimators, ExponentiatedGradient, GridSearch, DemographicParity, EqualizedOdds, BoundedGroupLoss, sample_weight_name sub-skills/reductions/SKILL.md Reductions owns algorithms that reduce fairness constraints to weighted supervised-learning problems.
Adjust a trained predictor with group-specific thresholds, ThresholdOptimizer, plot_threshold_optimizer, prefit, predict_method, post-fit parity constraints sub-skills/postprocessing/SKILL.md Postprocessing owns prediction-time threshold/interpolation mitigation.
Neural adversarial fairness, PyTorch or TensorFlow backends, callbacks, CUDA, AdversarialFairnessClassifier, AdversarialFairnessRegressor sub-skills/adversarial/SKILL.md Adversarial workflows have backend-specific model, optimizer, and training pitfalls.
Built-in datasets, fetch_adult, fetch_acs_income, fetch_boston, return_X_y, as_frame, data_home, dataset fairness caveats sub-skills/datasets/SKILL.md Dataset loaders have network/cache behavior and dataset-specific schemas.
Installing, checking versions, optional extras, missing matplotlib/torch/tensorflow, show_versions, import/runtime diagnostics sub-skills/installation/SKILL.md Installation owns environment and dependency recovery paths.

Operating rules

  • Treat Fairlearn as a sociotechnical fairness toolkit, not an automated fairness oracle. Metric choices and mitigation goals must be tied to the user's problem context.
  • Keep row alignment explicit. X, y_true/y, predictions, and sensitive_features must describe the same samples in the same order.
  • Use sensitive_features for group definitions even when those columns are also present in X. Do not assume ignoring sensitive features is enough to assess or mitigate unfairness.
  • Start with assessment before mitigation unless the user already gives a constrained mitigation algorithm and metric target.
  • Prefer tiny synthetic smoke checks or cached data before networked dataset downloads. Fairlearn dataset fetchers use OpenML-style downloads and cache under a data home.
  • Make optional dependencies explicit. Plotting requires matplotlib; adversarial mitigation requires either PyTorch or TensorFlow. The PyTorch CPU path and optional CUDA acceleration were verified for this skill; TensorFlow was only documented as an alternative.
  • The generated references and scripts are self-contained. Do not instruct future agents to open this repo's original docs, tests, examples, or source scripts for normal operation.

Shared runtime files

Good first branch decisions

  • If the prompt says "is my model fair?", "compare groups", or names a metric, start with assessment.
  • If it asks to transform features before training, start with preprocessing.
  • If it asks to train a fair model from scratch with a sklearn estimator, start with reductions.
  • If it already has a fitted predictor or score function and wants fair thresholds, start with postprocessing.
  • If it names neural networks, PyTorch, TensorFlow, callbacks, or CUDA, start with adversarial.
  • If it asks for Adult, ACSIncome, Boston, diabetes, bank, or credit-card sample data, start with datasets.
  • If imports, missing extras, or version questions block the task, start with installation and root troubleshooting.

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