Building the algorithm

Let's now build the naive Bayes classifier. These are the steps that are to be followed to build the algorithm :

  1. Create a new folder for the project called Ch5-Bayes. As usual, create src and data and dist folders, and add the following package.json file:
{ "name": "Ch5-Bayes", "version": "1.0.0", "description": "ML in JS Example for Chapter 5 - Bayes", "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 --presets [ env ] ]", "start": "yarn build-cli && node dist/index.js" }, "dependencies": { "babel-core": "^6.26.0", "babel-plugin-transform-object-rest-spread" ...

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.