mlt-node
v0.0.6
Published
Node port of the BYU CS 478 machine learning toolkit written in Typescript
Downloads
3
Maintainers
Readme
mlt-node
Node port of the BYU CS 478 machine learning toolkit written in typescript
Getting Started
- Install mlt-node
npm install mlt-node
- Download some datasets
mkdir datasets
wget http://axon.cs.byu.edu/~martinez/classes/478/stuff/iris.arff -P datasets/
- Write a program to take in parameters and call the toolkit. This can be as simple as:
import { SupervisedLearner, BaselineLearner, run } from 'mlt-node';
function getLearner(model: string): SupervisedLearner {
switch (model) {
case 'baseline':
return new BaselineLearner();
case 'perceptron':
// return new Perceptron();
case 'neuralnet':
// return new NeuralNet();
case 'decisiontree':
// return new DecisionTree();
case 'knn':
// return new InstanceBasedLearner();
default:
throw new Error('Unrecognized model: ' + model);
}
}
//Parse the command line arguments
const learnerName = process.argv[3];
run(getLearner(learnerName));
- Compile your typscript program and run
node compiledProgram.js -L baseline -A datasets/iris.arff -E training
Creating Learners
Creating new learners is as simple as extending the SupervisedLearner class provided by the toolkit. Just make sure to override the train()
and predict()
functions of the SupervisedLearner
base class.
import { Matrix, SupervisedLearner } from 'mlt-node';
class MyNewLearner extends SupervisedLearner {
train(features: Matrix, labels: Matrix) {
// Your training algorithm here.
}
predict(features: number[], labels: number[]) {
// Your prediction algorithm here.
}
}
Contributing
There are bound to be bugs in this project. Please help fix them by creating PRs.