Skip to content

Instantly share code, notes, and snippets.

@deedubs
Created November 11, 2011 20:17
Show Gist options
  • Save deedubs/1359107 to your computer and use it in GitHub Desktop.
Save deedubs/1359107 to your computer and use it in GitHub Desktop.
// Using machine learning to determine where people live.
var brain = require('brain');
var bayes = new brain.BayesianClassifier();
// Training the Machine about Toronto
bayes.train("Toronto, On", "Toronto");
bayes.train("Greater Toronto Area, Ontario", "Toronto");
bayes.train("toronto;on-canada", "Toronto");
bayes.train("T.O.", "Toronto");
// Training the Machine about Montreal
bayes.train("MTL", "Montreal");
bayes.train("Montreal, QC", "Montreal");
bayes.train("Montreal", "Montreal");
// Seeing what the machine thinks of 'T Dot'
var category = bayes.classify("T Dot");
console.log(category);
//
// Machine guesses Toronto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment