new KNN(elementsopt, metricopt) → {KNN}
Generates a KNN list with given elements
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
elements | Array | <optional> | null | Elements which should be added to the KNN list |
metric | function | | <optional> | euclidean | metric is either precomputed or a function to use: (a, b) => distance |
- Source
Returns:
- Type:
- KNN
Methods
search(t, kopt) → {Heap}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
t | Array | | query element or index. | ||
k | Number | <optional> | 5 | number of nearest neighbors to return. |
- Source
Returns:
- Heap consists of the
k
nearest neighbors.
- Type:
- Heap