JSPM

ml-nearest-vector

2.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 62679
  • Score
    100M100P100Q171779F
  • License MIT

Find the nearest point to a sample point

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

NPM version build status Test coverage David deps npm download

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]

License

MIT