0.7.7 • Published 10 months ago

tree-garden v0.7.7

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

tree-garden Types and tests

npm.io

Let`s bring a bit of machine-learning on the web! see tree-garden in action! (docs)

Peek in :

import {
  buildAlgorithmConfiguration,
  growTree,
  getTreeAccuracy,
  prune,
  sampleDataSets,
  dataSet,
  statistics,
  impurity
} from 'tree-garden';


const [training, validation] = dataSet.getDividedSet(sampleDataSets.titanicSet, 0.85);
console.log(`length of validation: ${validation.length}, length of training: ${training.length} `);


const myConfig = buildAlgorithmConfiguration(sampleDataSets.titanicSet, {
  excludedAttributes: ['name', 'ticket', 'embarked', 'cabin'], // exclude some attrs that we do not want to use
  attributes: { pclass: { dataType: 'discrete' }, parch: { dataType: 'discrete' }, sibs: { dataType: 'discrete' } }, // consider some number attributes as discrete values
  getScoreForSplit: impurity.getInformationGainRatioForSplit,
  biggerScoreBetterSplit: true
});

const tree = growTree(myConfig, training);
console.log(`UNPRUNED: Number of nodes,${statistics.getNumberOfTreeNodes(tree)} acc:${getTreeAccuracy(tree, validation, myConfig)}`);
const prunedTree = prune.getPrunedTreeByCostComplexityPruning(tree, sampleDataSets.titanicSet, myConfig);
console.log(`Pruned: Number of nodes,${statistics.getNumberOfTreeNodes(prunedTree)} acc:${getTreeAccuracy(prunedTree, validation, myConfig)}`);

// console.log(JSON.stringify(prunedTree));
0.7.7

10 months ago

0.7.6

1 year ago

0.7.5

1 year ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.0

1 year ago

0.6.5

1 year ago

0.6.4

1 year ago

0.6.3

1 year ago

0.6.2

1 year ago

0.6.1

1 year ago

0.6.0

2 years ago

0.5.12

2 years ago

0.5.11

2 years ago