Esempio n. 1
0
def sort(args) -> list:
    """Performs a sort based on the given args.
	Args is of the format (dist, auc, n0, n1) and is one tuple/list.
	Throws an error if the array did not sort correctly.
	Returns the results."""
    dist, auc, n0, n1 = args
    results = list()
    data, D0, D1 = continuousScale(n0, n1)
    comp = Comparator(data, level=0, rand=True)
    sep = genSep(dist, auc)
    comp.genRand(n0, n1, sep, dist)
    for arr, stats in treeMergeSort(data, comp, [(D0, D1), dist, auc], n=2):
        stats.extend([len(comp), comp.genSeps(), comp.pc[-1]])
        comp.resetPC()
        results.append(stats)
    if arr != sorted(arr, key=lambda x: comp.getLatentScore(x)[0]):
        print(arr)
        print(sorted(arr, key=lambda x: comp.getLatentScore(x)[0]))
        raise AssertionError("did not sort")
    return results
Esempio n. 2
0
                          update,
                          frames=np.arange(0, frames),
                          interval=100)
     anim.save("rocs.gif", writer=PillowWriter(fps=10))
     pbar.close()
 else:
     import matplotlib.pyplot as plt
     from apng import APNG
     from DylSort import treeMergeSort
     from DylComp import Comparator
     from DylData import continuousScale
     from DylMath import genROC, avROC
     seed = 15
     data, D0, D1 = continuousScale(128, 128)
     comp = Comparator(data, level=0, rand=True, seed=seed)
     comp.genRand(len(D0), len(D1), 7.72, 'exponential')
     np.random.seed(seed)
     im = APNG()
     fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2)
     fig.suptitle("Pass number, MSE true, MSE empirical")
     x = np.linspace(0, 1, num=200)
     y = x**(1 / 7.72)
     ax1.set_aspect('equal', 'box')
     ax2.set_aspect('equal', 'box')
     elo = simulation_ELO_targetAUC(True)
     merge = treeMergeSort(data,
                           comp,
                           statParams=[(D0, D1)],
                           combGroups=False)
     plt.tight_layout()
     for i in trange(8):