Socket
Socket
Sign inDemoInstall

ml-cart

Package Overview
Dependencies
7
Maintainers
7
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ml-cart

CART decision tree algorithm


Version published
Weekly downloads
1.1K
increased by6.87%
Maintainers
7
Install size
451 kB
Created
Weekly downloads
 

Changelog

Source

2.1.1 (2022-01-14)

Bug Fixes

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

Readme

Source

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

Keywords

FAQs

Last updated on 14 Jan 2022

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc