-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfalsifier.py
More file actions
73 lines (56 loc) · 2.04 KB
/
falsifier.py
File metadata and controls
73 lines (56 loc) · 2.04 KB
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
from verifai.features.features import *
from verifai.samplers.feature_sampler import *
from verifai.falsifier import generic_falsifier
from verifai.monitor import specification_monitor
from dotmap import DotMap
CONFIDENCE_THRESHOLD = 0.8
MAX_ITERS = 1000
PORT = 8888
MAXREQS = 5
BUFSIZE = 4096
class confidence_spec(specification_monitor):
def __init__(self):
def specification(traj):
# return bool(traj['yTrue'] == traj['yPred'])
return traj['confidence'] - CONFIDENCE_THRESHOLD
super().__init__(specification)
car1_domain = Struct({
'distance': Box([8, 16]),
'lane_order': Categorical(*np.arange(0, 6)),
'carID': Categorical(*np.arange(0, 27))
})
car2_domain = Struct({
'distance': Box([8, 16]),
'lane_order': Categorical(*np.arange(0, 2)),
'carID': Categorical(*np.arange(0, 27))
})
camera_domain = Struct({
'x': Box([0.5, 1.5]),
'z': Box([1.4, 2.5]),
'pitch': Box([-20, 0])
})
space = FeatureSpace({
'weatherID': Feature(Categorical(*np.arange(0, 24))),
'numCars': Feature(Categorical(*np.arange(0, 3))),
'townLocation': Feature(Box([0, 1])),
'car1': Feature(car1_domain),
'car2': Feature(car2_domain),
'camera': Feature(camera_domain),
'brightness': Feature(Box([0.5, 1])),
'sharpness': Feature(Box([0, 1])),
'contrast': Feature(Box([0.5, 1.5])),
'color': Feature(Box([0, 1]))
})
sampler = FeatureSampler.crossEntropySamplerFor(space)
falsifier_params = DotMap(n_iters=MAX_ITERS,
compute_error_table=True,
fal_thres=0.5,
verbosity=1)
server_options = DotMap(port=PORT, bufsize=BUFSIZE, maxreqs=MAXREQS)
falsifier = generic_falsifier(sampler=sampler, server_options=server_options,
monitor=confidence_spec(), falsifier_params=falsifier_params)
falsifier.run_falsifier()
analysis_params = DotMap()
falsifier.analyze_error_table(analysis_params=analysis_params)
print("Error table")
print(falsifier.error_table.table)