77from aalpy .utils .BenchmarkVpaModels import get_all_VPAs
88from statistics import mean , stdev
99
10+ # Load positive and negativ sequances for all models
1011all_data = dict ()
1112with open ('papni_sequences.pickle' , 'rb' ) as handle :
1213 all_data = pickle .load (handle )
@@ -59,6 +60,8 @@ def evaluate_model(learned_model, test_data):
5960 return [rpni_model .size , papni_model .size , rpni_error , papni_error ]
6061
6162
63+ # run KV for VPDA learning and record all sequences
64+ # these sequences should cover the whole characterizing set required to learn 1-SEVPA
6265def get_sequences_from_active_sevpa (model , verbose = False ):
6366 from aalpy import SUL , run_KV , RandomWordEqOracle , SevpaAlphabet
6467
@@ -165,25 +168,24 @@ def run_experiment(experiment_id,
165168
166169def run_experiments_multiple_times (test_models , num_times , learning_to_test_ratio = 0.5 ):
167170 all_results = defaultdict (list )
168- print (f'Running each experiment/ model { num_times } times.' )
171+ print (f'Running experiment on each model { num_times } times.' )
169172
170173 for idx , gt in enumerate (test_models ):
174+ print ('Experiment: ' , idx )
171175 for _ in range (num_times ):
172176 r = run_experiment (idx , gt , num_of_learning_seq = 10000 , max_learning_seq_len = 50 ,
173177 random_data_generation = False , learning_to_test_ratio = learning_to_test_ratio )
174178
175179 all_results [idx ].append (r )
176180
177- for exp_idx , result in all_results .items ():
178- print ('Experiment: ' , exp_idx )
179- rpni_results = [r [2 ] for r in result ]
180- papni_results = [r [3 ] for r in result ]
181+ rpni_results = [r [2 ] for r in all_results [idx ]]
182+ papni_results = [r [3 ] for r in all_results [idx ]]
181183
182184 rpni_f1 = [r [2 ] for r in rpni_results ]
183185 papni_f1 = [r [2 ] for r in papni_results ]
184186
185- print (f'RPNI : min { min (rpni_f1 )} , max { max (rpni_f1 )} , mean { mean (rpni_f1 )} , stddev { stdev (rpni_f1 )} ' )
186- print (f'PAPNI : min { min (papni_f1 )} , max { max (papni_f1 )} , mean { mean (papni_f1 )} , stddev { stdev (papni_f1 )} ' )
187+ print (f'RPNI (F1) : min { min (rpni_f1 )} , max { max (rpni_f1 )} , mean { mean (rpni_f1 )} , stddev { stdev (rpni_f1 )} ' )
188+ print (f'PAPNI (F1) : min { min (papni_f1 )} , max { max (papni_f1 )} , mean { mean (papni_f1 )} , stddev { stdev (papni_f1 )} ' )
187189 print ('----------------------------------------------------------------' )
188190
189191 import pickle
@@ -242,4 +244,4 @@ def test_papni_based_on_sevpa_dataset():
242244#test_papni_based_on_sevpa_dataset()
243245
244246all_models = get_all_VPAs ()
245- run_experiments_multiple_times (all_models , num_times = 2 )
247+ run_experiments_multiple_times (all_models , num_times = 20 , learning_to_test_ratio = 0.5 )
0 commit comments