JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4130
  • Score
    100M100P100Q123894F
  • License MIT

FPGrowth frequent itemset mining algorithm implementation in TypeScript / JavaScript.

Package Exports

  • node-fpgrowth

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-fpgrowth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Node-FPGrowth

FPGrowth Algorithm frequent itemset mining algorithm implementation in TypeScript / JavaScript.

Getting Started

Installing

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

Installation is done using the npm install command:

npm install --save node-fpgrowth

Example of use

In your TypeScript project, import and use FPGrowth as follows. Same example with a JavaScript syntax is available here.

import { FPGrowth, Itemset } from 'node-fpgrowth';

let transactions: number[][] = [
    [1,3,4],
    [2,3,5],
    [1,2,3,5],
    [2,5],
    [1,2,3,5]
];

// Execute FPGrowth with a minimum support of 40%. Algorithm is generic.
let fpgrowth: FPGrowth<number> = new FPGrowth<number>(.4);

// Returns itemsets 'as soon as possible' through events.
fpgrowth.on('data', (itemset: Itemset<number>) => {
    // Do something with the frequent itemset.
    let support: number = itemset.support;
    let items: number[] = itemset.items;
});

// Execute FPGrowth on a given set of transactions.
fpgrowth.exec(transactions)
    .then( (itemsets: Itemset<number>[]) => {
      // Returns an array representing the frequent itemsets.
    });

Node-FPGrowth is compatible with browserify and webpack. Alternatively, you can import/serve the browserified fpgrowth-client.js file found in the dist folder:

<script src="./dist/fpgrowth-client.js"></script>
<script>
  var transactions = [
      [1, 3, 4],
      [2, 3, 5],
      [1, 2, 3, 5],
      [2, 5],
      [1, 2, 3, 5]
  ];

  var fpg = new fpgrowth.FPGrowth(.4);

  fpg.exec(transactions, function (itemsets) {
      console.log(`Finished executing FPGrowth. ${itemsets.length} frequent itemset(s) were found.`);
  });
</script>

Building from source

  • Clone this repository:
    git clone https://github.com/alexisfacques/Node-FPGrowth.git
    cd Node-FPGrowth
  • Install the project's dependencies with:
    npm install
  • Compile the module's sources to executable JavaScript:
    npm run tsc
  • This should run the example bundled with the module:
    npm test
  • This should recreate a browserified version, ./dist/fpgrowth-client.js, of the module:
    npm run browserify

License

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