Socket
Book a DemoInstallSign in
Socket

@digifi/ml-cart

Package Overview
Dependencies
Maintainers
16
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digifi/ml-cart

CART decision tree algorithm

latest
Source
npmnpm
Version
1.0.8
Version published
Maintainers
16
Created
Source

ml-cart (Classification and regression trees)

NPM version build status Test coverage npm download

Decision trees using CART implementation.

Installation

npm install --save ml-cart

API documentation

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);

License

MIT

Keywords

CART

FAQs

Package last updated on 29 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts