nearest-neighbors
v4.0.8
Published
Find nearest neighbors & classify entities based on their neighbors
Downloads
13
Readme
nearest-neighbors
Find nearest neighbors & classify entities based on their neighbors
NearestNeighbors
Kind: global class
new NearestNeighbors()
constructor Initializes a machine for finding nearest neighbors.
nearestNeighbors.getNearestNeighbors(node, desiredNeighbors) ⇒ Array
Find the specified number of nearest neighbors for the provided node.
Kind: instance method of NearestNeighbors
Returns: Array - The nearest neighbors.
| Param | Type | Description | | --- | --- | --- | | node | Object | The node to find neighbors for. | | desiredNeighbors | Number | The number of neighbors to find. |
nearestNeighbors.setDistancesFromNeighbors(node) ⇒ undefined
Assigns a distance from supplied node to each neighbor.
Kind: instance method of NearestNeighbors
| Param | Type | Description | | --- | --- | --- | | node | Object | The node to find neighbors for. |
nearestNeighbors.getDistancesFromNeighbor(node, neighbor) ⇒ Array
Find the range adjusted distances from supplied node to a neighbor for each feature.
Kind: instance method of NearestNeighbors
Returns: Array - The distances from this node to the neighbor in each dimension.
| Param | Type | Description | | --- | --- | --- | | node | Object | The node to determine distances from. | | neighbor | Node | The neighbor to determine distances from. |
nearestNeighbors.classify(node, desiredNeighbors, key) ⇒ String
Classify an entity based on its neighbors.
Kind: instance method of NearestNeighbors
Returns: String - The infered classification.
| Param | Type | Description | | --- | --- | --- | | node | Object | The node to find neighbors for and classify. | | desiredNeighbors | Number | The number of neighbors to find. | | key | String | The key to infer a value for. |
Scripts
test
– run the tests
npm run test
coverage
– generate test coverage
npm run coverage
view-coverage
– view test coverage
npm run view-coverage
lint
– lint the codebase
npm run lint
write-readme
– generate the README
npm run write-readme
License
MIT @ Flip