-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval.py
54 lines (44 loc) · 2.22 KB
/
eval.py
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
import pandas as pd
import argparse
parser = argparse.ArgumentParser(description="Process VNN data and calculate statistics.")
parser.add_argument("file_path", type=str, help="Path to the input CSV file.")
parser.add_argument("output_path", type=str, help="Path to save the output CSV file.")
args = parser.parse_args()
columns = ['benchmark', 'model', 'property', 'prepare_time', 'result', 'time']
data = pd.read_csv(args.file_path, header=None, names=columns)
grouped = data.groupby(['benchmark', 'model'])
results = []
for (_, model), group in grouped:
group = group.sort_index(ascending=False)
clean_instance = group.iloc[:10]
unverifiable_instance = group.iloc[10:]
if len(group) < 10:
continue
clean_instance_unsat_ratio = round(
(clean_instance['result'].isin(['unsat', 'safe', 'true'])).mean() * 100,
2
)
clean_instance_sat_ratio = round(
(clean_instance['result'].isin(['sat', 'unsafe', 'false'])).mean() * 100,
2
)
unverifiable_instance_unsat_ratio = round(
(clean_instance['result'].isin(['unsat', 'safe', 'true'])).mean() * 100,
2
)
unverifiable_instance_sat_ratio = round(
(clean_instance['result'].isin(['sat', 'unsafe', 'false'])).mean() * 100,
2
)
has_unsound = (unverifiable_instance['result'].isin(['unsat', 'safe', 'true'])).any()
results.append({
'model_name': model,
'clean_instance_verified_ratio': clean_instance_unsat_ratio,
'clean_instance_falsified_ratio': clean_instance_sat_ratio,
'unverifiable_instance_verified_ratio': unverifiable_instance_unsat_ratio,
'unverifiable_instance_falsified_ratio': unverifiable_instance_sat_ratio,
'has_unsound': has_unsound
})
results_df = pd.DataFrame(results)
results_df.to_csv(args.output_path, index=False)
print(f"Analysis complete. Results saved to {args.output_path}")