def test_kdTrees(queryShape): global methodList, exp_name exp_name = 'kdTrees' methodList = ['pure', 'true', 'standard', 'hybrid', 'cell', 'noisymean'] # Params.maxHeight = 8 epsList = [0.1, 0.5, 1.0] data = data_readin() res_cube_abs = np.zeros((len(epsList), len(seedList), len(methodList))) res_cube_rel = np.zeros((len(epsList), len(seedList), len(methodList))) for j in range(len(seedList)): queryList = queryGen(queryShape, seedList[j]) kexp = KExp(data, queryList) for i in range(len(epsList)): for k in range(len(methodList)): p = Params(seedList[j]) p.Eps = epsList[i] if methodList[k] == 'pure': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_pure(p) elif methodList[k] == 'true': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_true(p) elif methodList[k] == 'standard': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_standard(p) elif methodList[k] == 'hybrid': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_hybrid(p) elif methodList[k] == 'noisymean': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_noisymean(p) elif methodList[k] == 'cell': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_cell(p) else: logging.error('No such index structure!') sys.exit(1) res_abs_summary = np.average(res_cube_abs, axis=1) res_rel_summary = np.average(res_cube_rel, axis=1) np.savetxt(Params.resdir + exp_name + '_abs_' + str(int(queryShape[0] * 10)) + '_' + str(int(queryShape[1] * 10)), res_abs_summary, fmt='%.4f') np.savetxt(Params.resdir + exp_name + '_rel_' + str(int(queryShape[0] * 10)) + '_' + str(int(queryShape[1] * 10)), res_rel_summary, fmt='%.4f')
def test_height(queryShape): heightList = [6, 7, 8, 9, 10] methodList = ['quad-opt', 'hybrid', 'cell', 'hilbert'] data = data_readin() res_cube_abs = np.zeros((len(heightList), len(seedList), len(methodList))) res_cube_rel = np.zeros((len(heightList), len(seedList), len(methodList))) for j in range(len(seedList)): queryList = queryGen(queryShape, seedList[j]) kexp = KExp(data, queryList) p = Params(seedList[j]) for i in range(len(heightList)): Params.maxHeight = heightList[i] for k in range(len(methodList)): if methodList[k] == 'quad-opt': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_opt(p) elif methodList[k] == 'hybrid': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_hybrid(p) elif methodList[k] == 'cell': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_cell(p) elif methodList[k] == 'hilbert': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Hilbert(p) else: logging.error('No such index structure!') sys.exit(1) res_abs_summary = np.average(res_cube_abs, axis=1) res_rel_summary = np.average(res_cube_rel, axis=1) for s in ['abs', 'rel']: summary = eval('res_' + s + '_summary') outName = Params.resdir + 'height_' + str(int(queryShape[0] * 10)) + '_' + str(int(queryShape[1] * 10)) + str outFile = open(outName, 'w') outFile.write('#; ' + '; '.join(methodList) + '\n') for i in range(len(heightList)): outFile.write(heightList[i]) for j in range(len(methodList)): outFile.write(' ' + summary[i, j]) outFile.write('\n') outFile.close()
def test_quadtreeOpt(queryShape): global methodList, exp_name exp_name = 'quadtreeOpt' methodList = ['Quad-baseline', 'Quad-geo', 'Quad-post', 'Quad-opt'] # Params.maxHeight = 10 epsList = [0.1, 0.5, 1.0] data = data_readin() res_cube_abs = np.zeros((len(epsList), len(seedList), len(methodList))) res_cube_rel = np.zeros((len(epsList), len(seedList), len(methodList))) for j in range(len(seedList)): queryList = queryGen(queryShape, seedList[j]) kexp = KExp(data, queryList) for i in range(len(epsList)): for k in range(len(methodList)): p = Params(seedList[j]) p.Eps = epsList[i] if methodList[k] == 'Quad-baseline': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_baseline(p) elif methodList[k] == 'Quad-geo': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_geo(p) elif methodList[k] == 'Quad-post': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_post(p) elif methodList[k] == 'Quad-opt': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_opt(p) else: logging.error('No such index structure!') sys.exit(1) res_abs_summary = np.average(res_cube_abs, axis=1) res_rel_summary = np.average(res_cube_rel, axis=1) np.savetxt(Params.resdir + exp_name + '_abs_' + str(int(queryShape[0] * 10)) + '_' + str(int(queryShape[1] * 10)), res_abs_summary, fmt='%.4f') np.savetxt(Params.resdir + exp_name + '_rel_' + str(int(queryShape[0] * 10)) + '_' + str(int(queryShape[1] * 10)), res_rel_summary, fmt='%.4f')
def test_quadtreeOpt(queryShape): global methodList, exp_name exp_name = 'quadtreeOpt' methodList = ['Quad-baseline', 'Quad-geo', 'Quad-post', 'Quad-opt'] # Params.maxHeight = 10 epsList = [0.1, 0.5, 1.0] data = data_readin() res_cube_abs = np.zeros((len(epsList), len(seedList), len(methodList))) res_cube_rel = np.zeros((len(epsList), len(seedList), len(methodList))) for j in range(len(seedList)): queryList = queryGen(queryShape, seedList[j]) kexp = KExp(data, queryList) for i in range(len(epsList)): for k in range(len(methodList)): p = Params(seedList[j]) p.Eps = epsList[i] if methodList[k] == 'Quad-baseline': res_cube_abs[i, j, k], res_cube_rel[ i, j, k] = kexp.run_Quad_baseline(p) elif methodList[k] == 'Quad-geo': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_geo(p) elif methodList[k] == 'Quad-post': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_post(p) elif methodList[k] == 'Quad-opt': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_opt(p) else: logging.error('No such index structure!') sys.exit(1) res_abs_summary = np.average(res_cube_abs, axis=1) res_rel_summary = np.average(res_cube_rel, axis=1) np.savetxt(Params.resdir + exp_name + '_abs_' + str(int(queryShape[0] * 10)) + '_' + str(int(queryShape[1] * 10)), res_abs_summary, fmt='%.4f') np.savetxt(Params.resdir + exp_name + '_rel_' + str(int(queryShape[0] * 10)) + '_' + str(int(queryShape[1] * 10)), res_rel_summary, fmt='%.4f')
def test_height(queryShape): heightList = [6, 7, 8, 9, 10] methodList = ['quad-opt', 'hybrid', 'cell', 'hilbert'] data = data_readin() res_cube_abs = np.zeros((len(heightList), len(seedList), len(methodList))) res_cube_rel = np.zeros((len(heightList), len(seedList), len(methodList))) for j in range(len(seedList)): queryList = queryGen(queryShape, seedList[j]) kexp = KExp(data, queryList) p = Params(seedList[j]) for i in range(len(heightList)): Params.maxHeight = heightList[i] for k in range(len(methodList)): if methodList[k] == 'quad-opt': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Quad_opt(p) elif methodList[k] == 'hybrid': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_hybrid(p) elif methodList[k] == 'cell': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Kd_cell(p) elif methodList[k] == 'hilbert': res_cube_abs[i, j, k], res_cube_rel[i, j, k] = kexp.run_Hilbert(p) else: logging.error('No such index structure!') sys.exit(1) res_abs_summary = np.average(res_cube_abs, axis=1) res_rel_summary = np.average(res_cube_rel, axis=1) for s in ['abs', 'rel']: summary = eval('res_' + s + '_summary') outName = Params.resdir + 'height_' + str(int( queryShape[0] * 10)) + '_' + str(int(queryShape[1] * 10)) + str outFile = open(outName, 'w') outFile.write('#; ' + '; '.join(methodList) + '\n') for i in range(len(heightList)): outFile.write(heightList[i]) for j in range(len(methodList)): outFile.write(' ' + summary[i, j]) outFile.write('\n') outFile.close()