knn BallTree

new BallTree(elementsopt, metricopt) → {BallTree}

Generates a BallTree with given elements.

Parameters:
NameTypeAttributesDefaultDescription
elementsArray<optional>
null

Elements which should be added to the BallTree

metricfunction<optional>
euclidean

metric to use: (a, b) => distance

Returns:
Type: 
BallTree

Methods

add(elements) → {BallTree}

Parameters:
NameTypeDescription
elementsArray.<*>

new elements.

Returns:
Type: 
BallTree
Parameters:
NameTypeAttributesDefaultDescription
t*

query element.

kNumber<optional>
5

number of nearest neighbors to return.

Returns:
  • Heap consists of the k nearest neighbors.
Type: 
Heap