Compact Prediction Tree
The library is based on these research papers:
$ npm i compact-prediciton-tree
import CPT from 'compact-prediction-tree'; let model = new CPT(); let data = [ ['hello', 'how', 'are', 'you'], ['hello', 'how', 'are', 'your', 'studies', 'going', '?'], ['This', 'is', 'a', 'test'], ['How', 'does', 'this', 'work'] ] model.train( data // Training Data ); let target = [ ['how', 'are'] ]; let predictions = model.predict( target, // Test input 2, // The number of last elements that will be used // to find similar sequences, (default: target.length) 2 // The number of predictions required. ); console.log(predictions) // [['you'], ['your']]
It works on Strings/Number sequences. Optimizations are pending such as compression of frequenct sequences. Pull requests are welcome!