npm.io
1.0.12 • Published 9 years ago

simplebrain

Licence
ISC
Version
1.0.12
Deps
2
Vulns
0
Weekly
0
Stars
1

simplebrain

A super simple way to think about machine learning

Library is in ALPHA

const lr = require('simplebrain').linearRegression;

const trained_model = lr.train([
  {"x" :  1, "y" : 2},
  {"x" :  2, "y" : 4},
  {"x" :  3, "y" : 5},
  {"x" :  4, "y" : 4},
  {"x" :  5, "y" : 5}
]);

const grade = lr.grade(trained_model, [
  {"x" :  1, "y" : 2},
  {"x" :  2, "y" : 4},
  {"x" :  3, "y" : 5},
  {"x" :  4, "y" : 4},
  {"x" :  5, "y" : 5}
]);

console.log(grade); // 0.8

API:

linearRegression
  • train([{x: 1, y: 1}, ...]) => Returns a model (If you are looking for b0 and b1 this is where to find it console.log(model))
  • grade(model, [{x: 1, y: 1}, {x: 1, y: 2}]) => Returns a grade / number