npm.io
1.0.1 • Published 5 years ago

alz-predictor

Licence
MIT
Version
1.0.1
Deps
0
Size
10 kB
Vulns
0
Weekly
0
Stars
12

ALZ predictor · GitHub license npm version PRs Welcome

ALZ predictor is a JavaScript library for symbols sequence prediction, based on Gopalratnam and Cook Active LeZi algorithm.

  • AI: ALZ predictor makes it possible to create proactive and smart UIs. Improve your application UX by adding a touch of artificial intelligence. Guess and prefetch required data to enhance performance.

  • Simple: Model each user action as a char, then train ALZ by simply adding them as they come (one by one). Predict next user action at any time.

  • Lightweight: No dependencies.

Installation

# Yarn
yarn add alz-predictor

# NPM
npm install --save alz-predictor

Usage

import Predictor from 'alz-predictor'

const predictor = new Predictor()
predictor.add('a')
predictor.add('b')
predictor.add('a')

const predictions = predictor.predict()

Examples

  • Prefetch data based on next user action prediction

Documentation

Constructor
const predictor = new Predictor()
Methods
  • add: add char to the sequence.
  • predict: get predictions object.
  • loadJSON: recover state from JSON.
Serialization
const predictor = new Predictor()
predictor.add('a')
predictor.add('b')

const json = JSON.stringify(predictor)

License

ALZ predictor is MIT licensed.

Keywords