1.0.1 • Published 3 years ago

alz-predictor v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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.