tree-similarity
Tree similarity in Javascript
Installation
npm install ml-tree-similarity
tree(a,b, from, to, [options])
Returns the tree similarity between two spectra in the format {'x':Array,'y':Array}
Options
- alpha - weights the relative importance of intensity vs. shift match
- beta - weights the relative importance of node matching and children matching
- gamma - controls the attenuation of the effect of chemical shift differences
- minWindow - smallest range to accept in x
- threshold - smallest range to accept in y
Calc
Calculates the tree-similarity
CreateTree
Creates the tree based in the input dataset
Example
var tree = require('ml-tree-similarity');
var a = {
'x': [1, 2, 3, 4, 5, 6, 7],
'y': [0.3, 0.7, 4, 0.3, 0.2, 5, 0.3]
};
var b = {
'x': [1, 2, 3, 4, 5, 6, 7],
'y': [0.3, 4, 0.7, 0.3, 5, 0.2, 0.3]
};
var A = tree.createTree(a.x, a.y, 1, 7).center.should.be.approximately(4.5,10e-4);
var ans = tree.calc(A, b, 1, 7);
console.log(ans);
Test
$ npm install
$ npm test
Authors
License
MIT