Esempio n. 1
0

print("Creating comparison figures")
all_tests = []
data = {}
nr_tests = 0
for folder in folders:
    paths = os.listdir(os.path.join(path, folder, sub_folder))
    nr_tests += len(paths)
    print("Folder", folder, "length", len(paths))
    all_tests.append(paths)
    data[folder] = []

for t in range(len(all_tests)):
    for data_path in all_tests[t]:
        json_data = util.open_json_result(os.path.join(path, folders[t], sub_folder, data_path))

        if type(json_data) is list:
            d = json_data[0]
        else:
            d = json_data
        data[folders[t]].append(d)

series = []
for folder in folders:
    pr_avg = util.average(data[folder], pr_key_y, pr_key_x)
    breakeven_points = util.find_breakeven(pr_avg, samples=30)
    print(folder, breakeven_points)
    series.append({"name": folder, "data": pr_avg, "breakeven": breakeven_points})
util.display_precision_recall_plot(series)
Esempio n. 2
0
lc_key_x = 'epoch'
lc_key_y = 'test_loss'



data = {}
nr_tests = 0
for folder in folders:
    data[folder] = {}
    for sub in sub_folders:
        paths = os.listdir(os.path.join(path, folder, sub['name']))
        nr_tests += len(paths)
        print("Folder", folder, "Sub-folder", sub['name'], "length", len(paths))
        data[folder][sub['name']] = []
        for data_path in paths:
            json_data = util.open_json_result(os.path.join(path, folder, sub['name'], data_path))
            if type(json_data) is list:
                d = json_data[0]
            else:
                d = json_data
            data[folder][sub['name']].append(d)


#Average and find breakeven points, for final series.
breakeven_points = {}
for folder in folders:
    breakeven_points[folder] = []
    for sub in sub_folders:
        pr_avg = util.average(data[folder][sub['name']], pr_key_y, pr_key_x)
        breakeven = util.find_breakeven(pr_avg, samples=4)
        breakeven_points[folder].append({"x": sub['value'], "y": breakeven[1]})
print("Creating comparison figures")
all_tests = []
data = {}
nr_tests = 0
for folder in folders:
    paths = os.listdir(os.path.join(path, folder, sub_folder))
    nr_tests += len(paths)
    print("Folder", folder, "length", len(paths))
    if folder != folders[0]:
        paths.sort(key=sorter)
    all_tests.append(paths)
    data[folder] = []

for t in range(len(all_tests)):
    for data_path in all_tests[t]:
        json_data = util.open_json_result(
            os.path.join(path, folders[t], sub_folder, data_path))

        if type(json_data) is list:
            d = json_data[0]
        else:
            d = json_data
        data[folders[t]].append(d)

series = []

manual_breakeven = [
    [0.513, 0.595, 0.687, 0.712], [0.337, 0.411, 0.462, 0.524]
]  #Very uneven curves is hard to approximate by polyfit. (finds breakeven automatically)
compare_series = []
for j, pr in enumerate(folders[1:]):
    pr_per_epoch = []