‚̧Ninja Parading Musically
    Wondering what‚Äôs next for npm?Check out our public roadmap! ¬Ľ

    ml-cart

    2.0.2¬†‚Äʬ†Public¬†‚Äʬ†Published

    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

    Install

    npm i ml-cart

    DownloadsWeekly Downloads

    433

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    41.7 kB

    Total Files

    10

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar