-
Notifications
You must be signed in to change notification settings - Fork 0
/
audit_owner_knn.mpc
42 lines (25 loc) · 1.16 KB
/
audit_owner_knn.mpc
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
from Compiler.script_utils import output_utils
from Compiler.script_utils.data import data
from Compiler import ml
from Compiler import library
from Compiler.script_utils.audit import knn
from Compiler.script_utils import config
import timers
class AuditConfig(config.BaseAuditModel):
K: int = 25 # knn K
mod_zscore_threshold: float = 2.5
program.options_from_args()
cfg = config.from_program_args(program.args, AuditConfig)
if not cfg.emulate:
program.use_trunc_pr = True
program.use_edabits = True
# program.use_split(4)
ml.set_n_threads(cfg.n_threads)
library.start_timer(timer_id=timers.TIMER_LOAD_DATA)
input_loader = data.get_input_loader(dataset=cfg.dataset, audit_trigger_idx=cfg.audit_trigger_idx, batch_size=cfg.batch_size, debug=cfg.debug, emulate=cfg.emulate, consistency_check=cfg.consistency_check, sha3_approx_factor=cfg.sha3_approx_factor)
library.stop_timer(timer_id=timers.TIMER_LOAD_DATA)
library.start_timer(timer_id=timers.TIMER_AUDIT)
result = knn.audit(input_loader, cfg, debug=cfg.debug)
library.stop_timer(timer_id=timers.TIMER_AUDIT)
for k, v in result.items():
output_utils.output_value_debug(name=k, value=v, repeat=False)