File size: 6,106 Bytes
4adaccc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# Optimal Regularization for Performative Learning

This repository contains code for the experiments in:

**Optimal Regularization for Performative Learning**  
Edwige Cyffers, Alireza Mirrokni, Marco Mondelli  
International Conference on Machine Learning (ICML), 2026

The main repository contains the original experiments for the paper. The folder
`neural_network_credit/` contains the additional neural-network experiment on the
`GiveMeSomeCredit` strategic-classification environment used for the rebuttal-stage
figure `metric_vs_lambda_final_acc.pdf`.

## Citation

```bibtex
@inproceedings{cyffers2026optimal,
  title     = {Optimal Regularization for Performative Learning},
  author    = {Cyffers, Edwige and Mirrokni, Alireza and Mondelli, Marco},
  booktitle = {Proceedings of the 43rd International Conference on Machine Learning},
  year      = {2026}
}
```

## Repository structure

```text
.
β”œβ”€β”€ proportional/                 # Synthetic Proportional setting
β”œβ”€β”€ real/                         # Real-data experiments
β”œβ”€β”€ out/                          # Generated outputs, not tracked
β”œβ”€β”€ neural_network_credit/        # Neural-network experiment
β”‚   β”œβ”€β”€ sweep_l2_for_delta.py
β”‚   β”œβ”€β”€ plot_metric_vs_lambda.py
β”‚   β”œβ”€β”€ ppnn_experiments.py
β”‚   └── scripts/
β”‚       └── utils_torch.py
β”œβ”€β”€ requirements-nn-credit.txt    # Legacy dependencies for neural_network_credit only
β”œβ”€β”€ pyproject.toml                # Main repository environment
└── README.md
```

Generated results and figures should be written under `out/` and should not be
committed.

## Main environment

The main experiments use the repository-level `pyproject.toml` and `uv.lock`.
For the existing code, use the main environment, for example:

```bash
uv sync
```

The neural-network credit experiment should **not** be run in this environment.
The reason is that the main environment uses a up-to-date Python stack,
including NumPy 2, whereas `whynot` is an old package and depends on the old
`gym==0.21.0` stack.

## Neural-network credit experiment

### Description

The neural-network experiment follows the strategic-classification setting of
Mofakhami, Mitliagkas, and Gidel, *Performative Prediction with Neural Networks*
(AISTATS 2023). It uses the `GiveMeSomeCredit` environment through the `whynot`
package. The performative shift is controlled by a parameter `delta`: after a
negative classification under the previous model, an individual may strategically
modify the manipulable features by copying the corresponding features of another
data point, with probability depending on `delta`.

For each value of `delta`, the code sweeps over the L2 regularization parameter
`lambda`, runs repeated risk minimization for a fixed number of deployments, and
reports the final test accuracy. The qualitative behavior reported in the paper
is that L2 regularization mitigates the accuracy drop caused by the performative
shift, and that the best regularization level increases with the strength of the
performative effect.

### Files

```text
neural_network_credit/
β”œβ”€β”€ sweep_l2_for_delta.py      # Runs one delta value across a grid of lambdas
β”œβ”€β”€ plot_metric_vs_lambda.py   # Builds the final lambda-sweep figure from .pkl outputs
β”œβ”€β”€ ppnn_experiments.py        # Experiment logic, strategic shift, plotting helpers
└── scripts/
    └── utils_torch.py         # Torch models and training/loss utilities
```


### Legacy environment for `whynot`

The `whynot` dependency is the fragile part. Use a separate Python 3.9 environment
and keep packaging tools old enough for `gym==0.21.0`.

Recommended setup:

```bash
python3.9 -m venv .venv-nn-credit
source .venv-nn-credit/bin/activate
python -m pip install --upgrade "pip==23.2.1" "setuptools==65.5.0" "wheel==0.38.4"
python -m pip install -r requirements-nn-credit.txt
```

Check that the credit environment imports correctly:

```bash
python - <<'PY'
import whynot.gym as gym
import torch

env = gym.make("Credit-v0")
data = env.initial_state.values()
print(data["features"].shape, data["labels"].shape)
print(torch.__version__)
PY
```


### Run the sweeps

The paper figure used the following grid:

```text
n_runs        = 2
num_iters     = 3
layers        = 2
learning_rate = 3e-4
test_frac     = 0.9
delta_grid    = [0.1, 0.3, 0.5, 0.7, 0.9]
l2_grid       = [0, 1e-5, 3e-5, 1e-4, 3e-4, 1e-3, 3e-3, 1e-2]
seeds         = 0, 1
```

Run all five sweeps from the repository root:

```bash
mkdir -p out/nn_credit

L2_GRID="0 1e-5 3e-5 1e-4 3e-4 1e-3 3e-3 1e-2"

for DELTA in 0.1 0.3 0.5 0.7 0.9; do
  python neural_network_credit/sweep_l2_for_delta.py \
    --out "out/nn_credit/delta_${DELTA}.pkl" \
    --delta "$DELTA" \
    --n-runs 2 \
    --num-iters 3 \
    --layers 2 \
    --learning-rate 3e-4 \
    --test-frac 0.9 \
    --l2-grid $L2_GRID
done
```

This creates:

```text
out/nn_credit/delta_0.1.pkl
out/nn_credit/delta_0.3.pkl
out/nn_credit/delta_0.5.pkl
out/nn_credit/delta_0.7.pkl
out/nn_credit/delta_0.9.pkl
```

### Plot the figure

From the repository root:

```bash
python neural_network_credit/plot_metric_vs_lambda.py \
  out/nn_credit/delta_0.1.pkl \
  out/nn_credit/delta_0.3.pkl \
  out/nn_credit/delta_0.5.pkl \
  out/nn_credit/delta_0.7.pkl \
  out/nn_credit/delta_0.9.pkl \
  --out-prefix out/nn_credit/metric_vs_lambda_final
```

This writes:

```text
out/nn_credit/metric_vs_lambda_final_acc.pdf
out/nn_credit/metric_vs_lambda_final_loss.pdf
```

The paper uses only:

```text
out/nn_credit/metric_vs_lambda_final_acc.pdf
```

### Relationship with Mofakhami et al. (AISTATS 2023)

The implementation builds on the public code accompanying Mofakhami, Mitliagkas,
and Gidel, *Performative Prediction with Neural Networks*. The retained files are
only the parts needed for the L2-regularization sweep and the final neural-network
figure. Exploratory notebooks, old result folders, local virtual environments,
Python caches, copied simulator files that are not imported by these scripts, and
all stored outputs were intentionally omitted.