def runKDTreeSizeAnalysis(argsdict, data, inlbl, fPath, fName, fileN, i):
    start = time.time()
    tree = KDTree(data, leaf_size=1)
    end = time.time()

    print tree.get_tree_stats()
    return tree.__sizeof__(), (end - start)
Esempio n. 2
0
from sklearn.neighbors import KDTree

for lfs in [1000]:
    startTime = time.perf_counter()
    kdt = KDTree(train, metric='euclidean', leaf_size=lfs)
    end_time = time.perf_counter()
    constructionTime = end_time - startTime

    startTime = time.perf_counter()
    dist, result = kdt.query(query, k=100, return_distance=True)
    end_time = time.perf_counter()
    searchTime = end_time - startTime

    kdTreeRecall = hp.returnRecall(result, groundTruth)
    avgDist = np.mean(dist)
    ktreeparams = kdt.get_tree_stats()
    reacll.append(kdTreeRecall)
    algorithm.append('k-D')
    construciotnTimes.append(constructionTime)
    searchTimes.append(searchTime)
    avgdistances.append(avgDist)

#BallTree
from sklearn.neighbors import BallTree

for lfs in [100]:
    startTime = time.perf_counter()
    bt = BallTree(train, metric='euclidean', leaf_size=lfs)
    end_time = time.perf_counter()
    constructionTime = end_time - startTime