2.0.0 • Published 9 years ago

k-nearest-neighbors v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

k-nearest-neighbors

Classify an entity based on its neighbors.

Example:

const KNearestNeighbors = require('k-nearest-neighbors')
const machine = new KNearestNeighbors([
  {
    x: 0,
    y: 0,
    class: 'good',
  },
  {
    x: 10,
    y: 10,
    class: 'bad',
  },
  {
    x: 1,
    y: 1,
    class: 'ugly',
  },
], [
  'x',
  'y',
])
machine.classify({
  x: 1,
  y: 1,
}, 1, 'class')
// → 'ugly'