npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

ml-cart

1.0.8 • Public • Published

CART (Classification and regression trees)

NPM version build status David deps npm download

Decision trees using CART implementation.

Installation

npm install --save ml-cart

Usage

As a classifier

import irisDataset from 'ml-dataset-iris';
import {DecisionTreeClassifier as DTClassifier} from 'ml-cart';
 
var trainingSet = irisDataset.getNumbers();
var predictions = irisDataset.getClasses().map(
    (elem) => irisDataset.getDistinctClasses().indexOf(elem)
);
 
var options = {
    gainFunction: 'gini',
    maxDepth: 10,
    minNumSamples: 3
};
 
var classifier = new DTClassifier(options);
classifier.train(trainingSet, predictions);
var result = classifier.predict(trainingSet);

As a regression

import {DecisionTreeRegression as DTRegression} from 'ml-cart';
 
var x = new Array(100);
var y = new Array(100);
var val = 0.0;
for (var i = 0; i < x.length; ++i) {
    x[i] = val;
    y[i] = Math.sin(x[i]);
    val += 0.01;
}
 
var reg = new DTRegression();
reg.train(x, y);
var estimations = reg.predict(x);

API documentation

License

MIT

install

npm i ml-cart

Downloadsweekly downloads

139

version

1.0.8

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability