Package Exports
- ml-nearest-vector
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ml-nearest-vector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
nearest-vector
Find the nearest point to a sample point
Installation
$ npm install ml-nearest-vector
API Documentation
Example
import nearestVector, {findNearestVector} from 'ml-nearest-vector');
const nearestVector = require('ml-nearest-vector');
let centers = [[1, 2, 1], [-1, -1, -1]];
// returns the index of the nearest vector
nearestVector(centers, [1, 2, 1]) === 0;
// returns the nearest vector itself
findNearstVector(centers, [1, 2, 1]); // [1, 2, 1]