Newton's Principia Mathematica
Miss any of our Open RFC calls?Watch the recordings here! »

node-apriori

1.0.0 • Public • Published

Node-Apriori

Apriori Algorithm implementation in TypeScript / JavaScript.

Getting Started

Performances

This implementation does not generate k-candidates as efficiently as it possibly could, as it adopts a brute-force approach: Every k-itemset is considered as a potential candidate, and an additional step is required to prune the unnecessary ones. More information about this question here.

The Apriori Algorithm is a great, easy-to-understand algorithm for frequent-itemset mining. However, faster and more memory efficient algorithms such as the FPGrowth Algorithm have been proposed since it was released.

If you need a more efficient frequent-itemset mining algorithm, consider checking out my implementation of the FPGrowth Algorithm.

Installing

This is a Node.js module available through the npm registry.

Installation is done using the npm install command:

$ npm install --save node-apriori

Example of use

 
import { Apriori, Itemset, IAprioriResults } from 'node-apriori';
 
let transactions: number[][] = [
    [1,3,4],
    [2,3,5],
    [1,2,3,5],
    [2,5],
    [1,2,3,5]
];
 
// Execute Apriori with a minimum support of 40%. Algorithm is generic.
let apriori: Apriori<number> = new Apriori<number>(.4);
 
// Returns itemsets 'as soon as possible' through events.
apriori.on('data', (itemset: Itemset<number>) => {
    // Do something with the frequent itemset.
    let support: number = itemset.support;
    let items: number[] = itemset.items;
});
 
// Execute Apriori on a given set of transactions.
apriori.exec(transactions)
    .then( (result: IAprioriResults<number>) => {
        // Returns both the collection of frequent itemsets and execution time in millisecond.
        let frequentItemsets: Itemset<number>[] = result.itemsets;
        let executionTime: number = result.executionTime;
    });
 
 

License

This project is licensed under the MIT License - see the LICENSE file for details

Install

npm i node-apriori

DownloadsWeekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar