DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Predicting Ad Viewability With XGBoost Regressor Algorithm
  • Floyd's Cycle Algorithm for Fraud Detection in Java Systems
  • Metal and the Simulated Annealing Algorithm
  • Balancing Security and UX With Iterative Experimentation

Trending

  • Contextual AI Integration for Agile Product Teams
  • Simplify Authorization in Ruby on Rails With the Power of Pundit Gem
  • Chaos Engineering for Microservices
  • Power BI Embedded Analytics — Part 2: Power BI Embedded Overview
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. MachineX: Why No One Uses an Apriori Algorithm for Association Rule Learning

MachineX: Why No One Uses an Apriori Algorithm for Association Rule Learning

Read this article in order to learn more about the Apriori algorithm.

By 
Akshansh Jain user avatar
Akshansh Jain
·
May. 31, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
13.0K Views

Join the DZone community and get the full member experience.

Join For Free

In my previous blog, MachineX: Two Parts of Association Rule Learning, we discussed that there are two parts in performing association rule learning, namely, frequent itemset generation and rule generation. In this blog, we are going to talk about one of the algorithms for frequent itemset generation, in other words, Apriori algorithm.

The Apriori Principle

Apriori algorithm uses the support measure to eliminate the itemsets with low support. The use of support for pruning candidate itemsets is guided by the following principle:

If an itemset is frequent, then all of its subsets must also be frequent.

The above principle is known as The Apriori Principle.

I have already explained what support is in one of my previous blogs, MachineX: Layman's guide to Association Rule Learning. To recall, support tells us how frequent is an item, or an itemset, in all of the dataset.

Consider the item lattice shown above. Suppose {c, d, e} is a frequent itemset. Then, all the transactions that contain {c, d, e} also contain {c, d}, {c, e}, {e, d}, {c}, {d} and {e}. So, these items also have to be frequent for {c, d, e} to be frequent. Conversely, if an itemset, suppose {a, b} is infrequent, then all of its supersets have to be infrequent too, which means that all the transactions, for example, {a, b, c}, {a, b, d}, etc. have to be infrequent too. So, all the transactions containing {a, b} can be immediately pruned. This strategy of trimming the exponential search space based on the support measure is known as support-based pruning. Such a pruning strategy is made possible by a key property of the support measure, that is, the support for an itemset never exceeds the support for its subsets. This property is also known as the anti-monotone property of the support measure.

Frequent Itemset Generation in Apriori Algorithm

Apriori algorithm uses support-based pruning to control the exponential growth of the candidate itemsets. Let's understand this with an example.

Let's suppose the minimum threshold value is 3. So, the itemsets with support value of 3 or greater than 3 would be considered frequent. In the 1-itemset, the greyed out values are the infrequent itemsets and rest are frequent. So, first of all, all the 1-itemsets in the given dataset is listed with their frequencies as shown in the 1-itemset table in the above figure. Then, 2-itemset table is generated using only those items of the 1-itemset table which are frequent, i.e., have their support values greater than or equal to 3. In this way, we only get 6 2-itemsets. If pruning wasn't done, we would have gotten 15 2-itemsets at this step. Further, we can eliminate all the 2-itemsets with support less than 3. After doing that, we get 4 2-itemsets using which we generate 3-itemsets, which is ultimately just 1. If no pruning was performed, we would have gotten a total of 41 itemsets, but after pruning, we get only 13 itemsets, a significant reduction.

Then Why Is It Not Being Used?

Well, even after being so simple and clear, it has some weaknesses. If the 1-itemset comes out to be very large, for ex. 10 4, then the 2-itemset candidate sets would be more than 10 7. Moreover, for a dataset with a large number of frequent items or with a low support value, the candidate itemsets will always be very large. These large datasets require a lot of memory to be stored in. Further, Apriori algorithm also scans the database multiple times to calculate the frequency of the itemsets in k-itemset. So, Apriori algorithm turns out to be very slow and inefficient, especially when memory capacity is limited and the number of transactions is large.

In my next blog, we are going to talk about one of the alternatives of Apriori algorithm: FP-Growth algorithm, which is a significant improvement over Apriori. Stay tuned!


Apriori algorithm Algorithm

Published at DZone with permission of Akshansh Jain, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Predicting Ad Viewability With XGBoost Regressor Algorithm
  • Floyd's Cycle Algorithm for Fraud Detection in Java Systems
  • Metal and the Simulated Annealing Algorithm
  • Balancing Security and UX With Iterative Experimentation

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!