Skip to content

A JavaScript sequence prediction library, for building proactive and smart user interfaces.

License

Notifications You must be signed in to change notification settings

mudafar/alz-predictor

Repository files navigation

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.

FAQ

  • Why JavaScript and Frontend AI at all?

  • How to save learning data?

    Serialize and save to browser localStorage.

  • What is the difference with Guess.js?

    Google Analytics is not required for training.

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

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.