k-nearest-neighbors
v2.0.0
Published
Classify an entity based on its neighbors.
Downloads
4
Readme
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'