Skip to content
Back to skills

Adversarial

ASecurity

"Use Fairlearn adversarial fairness estimators with PyTorch or

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 8, 2026
developmentpythongobashapibackend

Works with

  • api

Security analysis

A100/100

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

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill adversarial --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Adversarial?

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

Security grade badge for Adversarial
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-adversarial/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-adversarial)

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: adversarial
description: "Use Fairlearn adversarial fairness estimators with PyTorch or
  TensorFlow backends, callbacks, CUDA, and backend-specific troubleshooting."
disable-model-invocation: true
metadata:
  disco-role: operating
license: MIT
---

# Fairlearn adversarial

Use this sub-skill when the task asks for neural adversarial unfairness mitigation: `AdversarialFairnessClassifier`, `AdversarialFairnessRegressor`, PyTorch, TensorFlow, neural predictor/adversary models, callbacks, dynamic `alpha`, `warm_start`, CUDA, or backend import failures.

## Quick workflow

1. Confirm the selected backend is installed. PyTorch CPU and optional CUDA were verified for this skill; TensorFlow is documented but unverified here.
2. Prepare numeric 2D float features `X`, labels `y`, and row-aligned `sensitive_features`.
3. Define predictor and adversary models with compatible backend classes, or use Fairlearn's list model builder for simple experiments.
4. Construct the estimator with `backend`, model, optimizer, constraint, learning-rate, epoch, batch, callback, and CUDA settings.
5. Fit with `sensitive_features=...`.
6. Evaluate with `../assessment/`, watching for mode collapse, accuracy loss, or unchanged disparity.

## Read these references

- [`references/backends-and-training.md`](references/backends-and-training.md) for constructor fields, backend selection, model shapes, data preprocessing, callbacks, CUDA, and evaluation.
- [`references/troubleshooting.md`](references/troubleshooting.md) for missing backends, 2D input errors, invalid activations, BCE range failures, callbacks, and CUDA errors.
- [`scripts/smoke_torch_adversarial.py`](scripts/smoke_torch_adversarial.py) for a tiny explicit-PyTorch-model smoke check with optional CUDA.

## Core APIs to recognize

- `AdversarialFairnessClassifier(*, backend="auto", predictor_model=None, adversary_model=None, predictor_optimizer="Adam", adversary_optimizer="Adam", constraints="demographic_parity", learning_rate=0.001, alpha=1.0, epochs=1, batch_size=32, shuffle=False, progress_updates=None, skip_validation=False, callbacks=None, cuda=None, warm_start=False, random_state=None)`
- `AdversarialFairnessRegressor(...)` with the same constructor surface.
- Supported constraint strings in this family: `demographic_parity` and `equalized_odds`.

## Boundary rules

- This sub-skill owns neural adversarial mitigation only. Use `../reductions/` for sklearn-estimator constrained retraining and `../postprocessing/` for threshold adjustment.
- Use `../installation/` if backend installation is the main task.
- Use `../datasets/` for Adult/ACS data loading and `../assessment/` for final metric tables.
- Do not install TensorFlow or large GPU stacks unless the user explicitly chooses that backend.

## Operating rules

- `X` must be two-dimensional and numeric. One-hot encode categoricals and scale numeric columns before neural training.
- Labels and sensitive features are auto-preprocessed as binary, categorical, or continuous, but row alignment is still the caller's responsibility.
- Do not mix backends: PyTorch models/optimizers go with the PyTorch backend; Keras/TensorFlow models go with TensorFlow.
- In the inspected PyTorch engine, binary losses use `BCELoss`; custom binary predictor/adversary modules should output values in `[0, 1]`, usually with a final `torch.nn.Sigmoid()`.
- Adversarial training is sensitive to hyperparameters. Start tiny, validate often, and use callbacks for early stopping or learning-rate/alpha schedules.
- Use `cuda="cuda:0"` only after `torch.cuda.is_available()` is true; otherwise run CPU.

## Fast validation

CPU PyTorch smoke:

```bash
python sub-skills/adversarial/scripts/smoke_torch_adversarial.py
```

Optional CUDA smoke:

```bash
python sub-skills/adversarial/scripts/smoke_torch_adversarial.py --cuda cuda:0
```

Files in this skill

  • SKILL.md3.8 KB
  • references/backends-and-training.md5.9 KB
  • references/troubleshooting.md2.4 KB
  • scripts/smoke_torch_adversarial.py3.4 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.