0.0.5 • Published 7 years ago

mlt-ts v0.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

mlt-ts

Typescript port of the BYU CS 478 machine learning toolkit

Getting Started

  1. Install mlt-ts
npm install mlt-ts
  1. Download some datasets
mkdir datasets
wget http://axon.cs.byu.edu/~martinez/classes/478/stuff/iris.arff -P datasets/
  1. Write a program to take in parameters and call the toolkit. This can be as simple as:
import { SupervisedLearner, BaselineLearner, run } from './malt';

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));
  1. 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-ts';

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.

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago