GithubHelp home page GithubHelp logo

chen0040 / java-frequent-pattern-mining Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 4.0 66 KB

Package provides java implementation of frequent pattern mining algorithms such as apriori, fp-growth

License: MIT License

Shell 15.58% Batchfile 12.03% Java 72.39%
frequent-itemsets frequent-pattern-mining frequent-pattern-trees association-rules pattern-discovery java fp-growth apriori

java-frequent-pattern-mining's Introduction

java-frequent-pattern-mining

Package provides java implementation of frequent pattern mining algorithms such as apriori, fp-growth

Build Status Coverage Status

Features

  • Apriori
  • FP-Growth

Install

Add the following dependency to your POM file:

<dependency>
  <groupId>com.github.chen0040</groupId>
  <artifactId>java-frequent-pattern-mining</artifactId>
  <version>1.0.1</version>
</dependency>

Usage

FP Growth

The sample code below shows how to use FPGrowth to obtain the frequent item sets from a list of transactions

 List<List<String>> database = new ArrayList<>();

// each line below add a new transaction to the database
database.add(Arrays.asList("f", "a", "c", "d", "g", "i", "m", "p"));
database.add(Arrays.asList("a", "b", "c", "f", "l", "m", "o"));
database.add(Arrays.asList("b", "f", "h", "j", "o", "w"));
database.add(Arrays.asList("b", "c", "k", "s", "p"));
database.add(Arrays.asList("a", "f", "c", "e", "l", "p", "m", "n"));

AssocRuleMiner method = new FPGrowth();
method.setMinSupportLevel(2);

MetaData metaData = new MetaData(database);

// obtain all frequent item sets with support level not below 2
ItemSets frequent_item_sets = method.minePatterns(database, metaData.getUniqueItems());
fis.stream().forEach(itemSet -> System.out.println("item-set: " + itemSet));

// obtain the max frequent item sets
ItemSets max_frequent_item_sets = method.findMaxPatterns(database, metaData.getUniqueItems());

Apriori

The sample code below shows how to use Apriori to obtain the frequent item sets from a list of transactions

List<List<String>> database = new ArrayList<>();

// each line below add a new transaction to the database
database.add(Arrays.asList("f", "a", "c", "d", "g", "i", "m", "p"));
database.add(Arrays.asList("a", "b", "c", "f", "l", "m", "o"));
database.add(Arrays.asList("b", "f", "h", "j", "o", "w"));
database.add(Arrays.asList("b", "c", "k", "s", "p"));
database.add(Arrays.asList("a", "f", "c", "e", "l", "p", "m", "n"));

AssocRuleMiner method = new Apriori();
method.setMinSupportLevel(2);

MetaData metaData = new MetaData(database);

// obtain all frequent item sets with support level not below 2
ItemSets frequent_item_sets = method.minePatterns(database, metaData.getUniqueItems());
fis.stream().forEach(itemSet -> System.out.println("item-set: " + itemSet));

// obtain the max frequent item sets
ItemSets max_frequent_item_sets = method.findMaxPatterns(database, metaData.getUniqueItems());

java-frequent-pattern-mining's People

Contributors

chen0040 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.