Building the KNN algorithm

Since the KNN algorithm is quite simple, we'll build our own implementation:

  1. Create a new folder and name it Ch5-knn.
  2. To the folder, add the following package.json file. Note that this file is a little different from previous examples because we have added a dependency for the jimp library, which is an image processing library that we'll use in the second example:
{  "name": "Ch5-knn",  "version": "1.0.0",  "description": "ML in JS Example for Chapter 5 - k-nearest-neighbor",  "main": "src/index.js",  "author": "Burak Kanber",  "license": "MIT",  "scripts": {    "build-web": "browserify src/index.js -o dist/index.js -t [ babelify --presets [ env ] ]",    "build-cli": "browserify src/index.js --node -o dist/index.js -t [ babelify ...

Get Hands-on Machine Learning with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.