Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
time plot edit
Browse files Browse the repository at this point in the history
use pure attack time if recorded, bwd-compat.
  • Loading branch information
nkrusch committed Dec 21, 2023
1 parent 5107f43 commit f66a3bc
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions plot/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,32 @@ def fmt(r):
v['n_constraints'], len(i), len(p), f"{f:.1f}"])

mat = self.ulist(fmt)
hdr = 'exp-name,records,cls,ft,*val,#C,⊥,P,ft/P'
hdr = 'exp-name,records,cls,#ft,*-val,#C,#⊥,#P,ft/P'
return self.make_table('config', hdr, mat)

def duration_plot(self, baseline: ResultData):
if baseline.n_results != self.n_results:
return

def fmt(r):
c, n, a = self.cls(r), self.name(r), self.attack(r)
cls, name, attack = self.cls(r), self.name(r), self.attack(r)
k = r['experiment']['k_folds']
z, t, s = -1, r['experiment']['duration_sec'] / k, '-'
ba = a[1:] if (a[0] == 'V' or (
a == 'CPGD' and 'original'
not in self.directory)) else a
if b := baseline.find(c, n, ba):
z = b['experiment']['duration_sec'] / k
s = f"{t / z:.2f}" if z != 0 else s
return [c, n, a, f"{z:.0f}", f"{t:.0f}", s]
t0, t0f, s = -1, f"{'-':>7}", f"{'-':>7}"
use_attack_dur = 'dur' in r['folds']
t = (mean(r['folds']['dur']) / 1e9) if use_attack_dur \
else r['experiment']['duration_sec'] / k
ba = attack[1:] if (attack[0] == 'V' or (
attack == 'CPGD' and 'original'
not in self.directory)) else attack
if b := baseline.find(cls, name, ba):
if use_attack_dur:
if 'dur' in b['folds']:
t0 = (mean(b['folds']['dur']) / 1e9)
if t0 == -1:
t0 = b['experiment']['duration_sec'] / k
s = f"{(t / t0):.2f}" if t0 != 0 else s
t0f = f"{t0:.0f}"
return [cls, name, attack, t0f, f"{t:.0f}", s]

hdr = 'classifier,exp-name,attack,t0,t(s),t-ratio'
mat = [fmt(r) for r in self.raw_rata]
Expand Down

0 comments on commit f66a3bc

Please sign in to comment.