txus commited on
Commit
528e4d0
·
verified ·
1 Parent(s): dca4226

Upload analyze.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. analyze.py +27 -3
analyze.py CHANGED
@@ -156,6 +156,29 @@ def claim34(paths):
156
  "final_se2": float(2 * np.nanstd(v[:, -1]) / np.sqrt(len(good))),
157
  }
158
  n_policy_chosen = n_dep - 1 # the first drifter is placed uniformly at random
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  return {
160
  "n_runs": len(good),
161
  "policies": pols,
@@ -165,9 +188,10 @@ def claim34(paths):
165
  "err_mean": {p: E[p].mean(0).tolist() for p in pols},
166
  "err_se2": {p: (2 * E[p].std(0) / np.sqrt(len(good))).tolist() for p in pols},
167
  "iso": iso,
168
- "savings_pct": {
169
- p: 100 * iso[p]["final"] / n_policy_chosen for p in pols
170
- },
 
171
  "n_obs_mean": {
172
  p: float(np.mean([r["n_obs"] for r in res if r["policy"] == p])) for p in pols
173
  },
 
156
  "final_se2": float(2 * np.nanstd(v[:, -1]) / np.sqrt(len(good))),
157
  }
158
  n_policy_chosen = n_dep - 1 # the first drifter is placed uniformly at random
159
+
160
+ # The paper defines iso-performance as "averaged over each iteration's
161
+ # results" (Sec. 5.2) and reports the saving as a single number ("save about
162
+ # 3 drifters ~16%"). We therefore headline the mean over deployment
163
+ # iterations, which matches the paper's Claim-3 number almost exactly (3.4 vs
164
+ # 3). The final-iteration value ("drifters needed to match uniform's *final*
165
+ # accuracy") is a different, larger statistic and is kept as a secondary read.
166
+ iso_avg = {p: float(np.nanmean(iso[p]["mean"])) for p in pols}
167
+ iso_avg_se2 = {
168
+ p: float(2 * np.nanstd([np.nanmean(
169
+ [iso_performance(E[p][i], E["unif"][i])]) for i in range(len(good))])
170
+ / np.sqrt(len(good)))
171
+ for p in pols
172
+ }
173
+ # per-run averaged-over-iterations, for a correct standard error
174
+ iso_avg_runs = {
175
+ p: np.array([np.nanmean(iso_performance(E[p][i], E["unif"][i]))
176
+ for i in range(len(good))])
177
+ for p in pols
178
+ }
179
+ iso_avg = {p: float(np.nanmean(iso_avg_runs[p])) for p in pols}
180
+ iso_avg_se2 = {p: float(2 * np.nanstd(iso_avg_runs[p]) / np.sqrt(len(good)))
181
+ for p in pols}
182
  return {
183
  "n_runs": len(good),
184
  "policies": pols,
 
188
  "err_mean": {p: E[p].mean(0).tolist() for p in pols},
189
  "err_se2": {p: (2 * E[p].std(0) / np.sqrt(len(good))).tolist() for p in pols},
190
  "iso": iso,
191
+ "iso_avg": iso_avg, # paper's metric: averaged over iterations
192
+ "iso_avg_se2": iso_avg_se2,
193
+ "savings_pct_avg": {p: 100 * iso_avg[p] / n_policy_chosen for p in pols},
194
+ "savings_pct_final": {p: 100 * iso[p]["final"] / n_policy_chosen for p in pols},
195
  "n_obs_mean": {
196
  p: float(np.mean([r["n_obs"] for r in res if r["policy"] == p])) for p in pols
197
  },