Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ml-cart

mljs26.6kMIT2.1.1

CART decision tree algorithm

CART, decision, tree, data, mining, datamining, machine, learning, regression

readme

ml-cart (Classification and regression trees)

NPM version build status npm download

Decision trees using CART implementation.

Installation

npm i ml-cart

API documentation

Usage

As a classifier

import irisDataset from 'ml-dataset-iris';
import { DecisionTreeClassifier as DTClassifier } from 'ml-cart';

const trainingSet = irisDataset.getNumbers();
const predictions = irisDataset
  .getClasses()
  .map((elem) => irisDataset.getDistinctClasses().indexOf(elem));

const options = {
  gainFunction: 'gini',
  maxDepth: 10,
  minNumSamples: 3,
};

const classifier = new DTClassifier(options);
classifier.train(trainingSet, predictions);
const result = classifier.predict(trainingSet);

As a regression

import { DecisionTreeRegression as DTRegression } from 'ml-cart';

const x = new Array(100);
const y = new Array(100);
const val = 0.0;
for (let i = 0; i < x.length; ++i) {
  x[i] = val;
  y[i] = Math.sin(x[i]);
  val += 0.01;
}

const reg = new DTRegression();
reg.train(x, y);
const estimations = reg.predict(x);

License

MIT

changelog

Changelog

2.1.1 (2022-01-14)

Bug Fixes

  • changes to fix issues 9, 15, 17, 28, 32 in random-forest (#20) (134da30)

2.1.0 (2021-07-30)

Features

2.0.2 (2020-10-18)

Bug Fixes

2.0.1 (2019-10-13)

Bug Fixes

  • correct bug on number of classes calculation (#10) (1f0d853)

2.0.0 (2019-06-29)

chore

  • update dependencies and remove support for Node.js 6 (f3bb07c)

BREAKING CHANGES

  • Node.js 6 is no longer supported.

1.0.8 (2017-07-28)

Bug Fixes

  • remove exports and don't export as object (#8) (4ceff09), closes #7
  • remove separate exports to one export to fix bug on import (ac5ee58)

1.0.7 (2017-07-26)

Bug Fixes

  • remove separate exports to one export to fix bug on import (ac5ee58)

1.0.6 (2017-07-26)

Bug Fixes

  • bug when trying to access to transpose view elements (test added) (0646ece)

1.0.5 (2017-07-26)

1.0.4 (2017-07-26)

1.0.3 (2017-07-22)

1.0.2 (2017-07-22)

1.0.1 (2016-12-17)

1.0.0 (2016-12-17)

0.0.1 (2016-07-08)

0.0.0 / HEAD

  • first release