Skip to content

Commit 0ab1b13

Browse files
authored
Merge pull request #200 from galilasmb/master
Fixing best combination
2 parents d71b493 + 9722de8 commit 0ab1b13

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scripts/experiment_static_analysis/generate_best_combination.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def convert_list_to_tuple(out):
297297
result = []
298298
for index in range(len(out[0])):
299299
val = [x[index] for x in out]
300-
result.append(tuple(val))
300+
result.append(tuple(float(v) for v in val))
301301
return concat_tuple(result)
302302

303303
info_LOI = ['project', 'class', 'method', 'merge commit']
@@ -358,7 +358,7 @@ def convert_list_to_tuple(out):
358358

359359
data = {
360360
'Metric': ['Precision', 'Recall', 'F1-score', 'Accuracy'],
361-
'Value': [round(best.higher_precision_value, 2), round(best.higher_recall_value, 2), round(best.higher_F1_value, 2), round(best.higher_accuracy_value, 2)],
361+
'Value': [round(float(best.higher_precision_value), 2), round(float(best.higher_recall_value), 2), round(float(best.higher_F1_value), 2), round(float(best.higher_accuracy_value), 2)],
362362
'Analyses': [str(to_string_as_set(get_reverse_name(remove_nested_best(best.higher_precision_analyses_names))))[:255],
363363
str(to_string_as_set(get_reverse_name(remove_nested_best(best.higher_recall_analyses_names))))[:255],
364364
str(to_string_as_set(get_reverse_name(remove_nested_best(best.higher_F1_analyses_names))))[:255],
@@ -490,7 +490,12 @@ def convert_list_to_tuple(out):
490490
actual_dict = best.confusion_matrix(count_fp_fn(m_smaller), smaller)
491491
l_aux = []
492492
for m in merged_dict['Metrics']:
493-
l_aux.append(format(actual_dict[m], '.2f'))
493+
#l_aux.append(format(actual_dict[m], '.2f'))
494+
try:
495+
l_aux.append(format(float(actual_dict[m]), '.2f'))
496+
except ValueError:
497+
print(f"ValueError: Cannot convert {actual_dict[m]} to float.")
498+
l_aux.append(actual_dict[m])
494499

495500
original_name = sum(get_reverse_name([smaller]), [])
496501
key = ' or '.join(original_name)

0 commit comments

Comments
 (0)