def runBallTreeSizeAnalysis(argsdict, data, inlbl, fPath, fName, fileN, i):
    start = time.time()
    tree = BallTree(data, leaf_size=1)
    end = time.time()
    print tree.get_tree_stats()

    return sys.getsizeof(tree), (end - start)
Esempio n. 2
0
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

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

    ballTreeRecall = hp.returnRecall(result, groundTruth)
    avgDist = np.mean(dist)
    ballTreeparams = bt.get_tree_stats()
    reacll.append(ballTreeRecall)
    algorithm.append('ball-tree')
    construciotnTimes.append(constructionTime)
    searchTimes.append(searchTime)
    avgdistances.append(avgDist)

compareResults = pd.DataFrame({
    'algorithm': algorithm,
    'constructionTime': construciotnTimes,
    'searchTime': searchTimes,
    'recall': reacll,
    'avgDistance': avgdistances
})

#Annoy