Git Product home page Git Product logo

apriori's Introduction

apriori

Java implementation of Apriori algorithm

In data mining, Apriori is a classic algorithm for learning association rules.

It is used for mining frequent itemsets and relevant association rules. It is devised to operate on a database containing a lot of transactions, for instance, items brought by customers in a store.

Finding Frequent Item Sets

The search for frequent item sets aims at finding items, which often occur collectively in a transaction.

  • Support metric - Support (BANANA -> EGGS) = Number of transactions containing both / Number of all transactions
  • Confidence metric - Confidence (BANANA -> EGGS) = Number of transactions containing both / Number of transactions containing BANANA
TransactionId Applications
123 APPLE, CUCUMBER, DATES
456 BANANA, CUCUMBER, EGGS
789 APPLE, BANANA, CUCUMBER, EGGS
911 BANANA, EGGS

The most frequent items are: BANANA, CUCUMBER, EGGS

Frequency is calculated base on threshold which by default is 60% of all applications. (For above example - 2).

What is the advantage of this library?

Main advantage of library is that it is extremely lightweight and simple for usage.

  • No need for external libraries.
  • No need for deep machine learning knowedge.
  • No need for complex wrappers and castings between user data and algorithm objects.

Usage

Users have to map their custom Objects to Apriori's Iteam & Application Objects. Let's see the following example: Custom user's class:

Unit {
  String value = "value";
  ...
}

Where "value" field is unique identifier (it will be used for classification) for the Unit. Let's assume that user stores in database applications (collections) of Units (where application is logical group of Units consolidated by transaction). In order to calculate Apriori needs the following mapping:

Item item = new Item(Unit.value); 
or
Item item = new Item(Unit.value, Unit); 

Then translate user's applications of Units to applications of Items.

Application application = new Application(new ArrayList<Item>(Arrays.asList(item));
...
// Transate every application then store them in list
List<Application> apps = new ArrayList<>();
apps.add(application);
...

Once we have a list of Applications Apriori is ready to work.

 Apriori apriori = new Apriori(apps);
 // Most common items
Set<Item> recomendedItems = apriori.recommend();

apriori's People

Contributors

zahariivanov87 avatar

Stargazers

 avatar  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.