O librarie simpla pentru machine learning in node.js

Machine-learning for Node.js erelsgl/limdu

Cateva exemple:

Exemplu 1:

var limdu = require(‘limdu’);

var colorClassifier = new limdu.classifiers.NeuralNetwork();

colorClassifier.trainBatch([
{input: { r: 0.03, g: 0.7, b: 0.5 }, output: 0}, // black
{input: { r: 0.16, g: 0.09, b: 0.2 }, output: 1}, // white
{input: { r: 0.5, g: 0.5, b: 1.0 }, output: 1} // white
]);

console.log(colorClassifier.classify({ r: 1, g: 0.4, b: 0 })); // 0.99 - almost white

Exemplu 2:

var birdClassifier = new limdu.classifiers.Winnow({
default_positive_weight: 1,
default_negative_weight: 1,
threshold: 0
});

birdClassifier.trainOnline({‘wings’: 1, ‘flight’: 1, ‘beak’: 1, ‘eagle’: 1}, 1); // eagle is a bird (1)
birdClassifier.trainOnline({‘wings’: 0, ‘flight’: 0, ‘beak’: 0, ‘dog’: 1}, 0); // dog is not a bird (0)
console.dir(birdClassifier.classify({‘wings’: 1, ‘flight’: 0, ‘beak’: 0.5, ‘penguin’:1})); // initially, penguin is mistakenly classified as 0 - “not a bird”
console.dir(birdClassifier.classify({‘wings’: 1, ‘flight’: 0, ‘beak’: 0.5, ‘penguin’:1}, /explanation level=/4)); // why? because it does not fly.

birdClassifier.trainOnline({‘wings’: 1, ‘flight’: 0, ‘beak’: 1, ‘penguin’:1}, 1); // learn that penguin is a bird, although it doesn’t fly
birdClassifier.trainOnline({‘wings’: 0, ‘flight’: 1, ‘beak’: 0, ‘bat’: 1}, 0); // learn that bat is not a bird, although it does fly
console.dir(birdClassifier.classify({‘wings’: 1, ‘flight’: 0, ‘beak’: 1, ‘chicken’: 1})); // now, chicken is correctly classified as a bird, although it does not fly.
console.dir(birdClassifier.classify({‘wings’: 1, ‘flight’: 0, ‘beak’: 1, ‘chicken’: 1}, /explanation level=/4)); // why? because it has wings and beak.

Personal nu stiu sa implementez nici un algoritm de machine learning de la zero, dar cred ca este important sa stii sa alegi algoritmul potrivit dintr-o librarie pentru o problema, si de a modela corect input-ul si output-ul, un articol pe tema asta spunea ca e important sa ii dai si un set de date suficient de mare de antrenament ca sa poata sa iti dea un output apropiat de valoarea corecta pentru un input dat.

2 Likes

Pentru cine are curiozitatea si vrea sa inteleaga logica din spatele algoritmilor de machine learning
A Visual Introduction to Machine Learning

1 Like