subsampling.py 1.18 KB
Newer Older
1 2
import matplotlib.pyplot as plt
import time
3

4 5
from evaluation import TotalResults, SampleResult
from input_output import get_pkls_from_directory, get_attributes_from_foldername
6

Josef Brandt's avatar
Josef Brandt committed
7 8 9 10
"""
IMPORTANT!!!
SET GEPARD TO EVALUATION BRANCH (WITHOUT THE TILING STUFF), OTHERWISE SOME OF THE LEGACY CONVERTS MIGHT FAIL..
"""
11 12


Josef Brandt's avatar
Josef Brandt committed
13
results: TotalResults = TotalResults()
14 15 16 17 18 19 20 21
pklsInFolders = get_pkls_from_directory(r'C:\Users\xbrjos\Desktop\temp MP\NewDatasets')

for folder in pklsInFolders.keys():
    for samplePath in pklsInFolders[folder]:
        newSampleResult: SampleResult = results.add_sample(samplePath)
        for attr in get_attributes_from_foldername(folder):
            newSampleResult.set_attribute(attr)

Josef Brandt's avatar
Josef Brandt committed
22 23 24
t0 = time.time()
results.update_all()
print('updating all took', time.time()-t0, 'seconds')
25 26 27 28 29 30 31 32 33 34 35 36 37 38

errorPerFraction: dict = results.get_error_vs_fraction_data()
plt.clf()
for methodLabel in errorPerFraction.keys():
    fractions: list = list(errorPerFraction[methodLabel].keys())
    errors: list = list(errorPerFraction[methodLabel].values())
    plt.plot(fractions, errors, label=methodLabel)

plt.xscale('log')
plt.xlabel('measured fraction')
plt.ylabel('mpCountError')
plt.legend()
plt.show()
print('done')