title: Frequent Itemsets & Association Rules - Apriori Algorithm
body: <p>I'm trying to understand the fundamentals of the Apriori (Basket) Algorithm for use in data mining,</p>
  
  <p>It's best I explain the complication i'm having with an example:</p>
  
  <p>Here is a transactional dataset:</p>
  
  <pre><code>t1: Milk, Chicken, Beer
  t2: Chicken, Cheese
  t3: Cheese, Boots
  t4: Cheese, Chicken, Beer
  t5: Chicken, Beer, Clothes, Cheese, Milk
  t6: Clothes, Beer, Milk
  t7: Beer, Milk, Clothes</code></pre>
  
  <p>The <strong>minsup for the above is 0.5 or 50%.</strong></p>
  
  <p>Taking from the above, my number of <strong>transactions is clearly 7</strong>, meaning for an itemset to be "frequent" it must have a count of <em>4/7</em>. As such this was my Frequent itemset 1:</p>
  
  <p><strong>F1:</strong></p>
  
  <pre><code>Milk = 4
  Chicken = 4
  Beer = 5
  Cheese = 4</code></pre>
  
  <p>I then created my candidates for the second refinement (C2) and narrowed it down to:</p>
  
  <p><strong>F2:</strong></p>
  
  <pre><code>{Milk, Beer} = 4</code></pre>
  
  <p>This is where I get confused, if I am asked to display <em>all</em> frequent itemsets do I write down all of <code>F1</code> and <code>F2</code> or just <code>F2</code>? <code>F1</code> to me aren't "sets".</p>
  
  <p>I am then asked to create association rules for the frequent itemsets I have just defined and calculate their "confidence" figures, I get this:</p>
  
  <pre><code>Milk -> Beer = 100% confidence
  Beer -> Milk = 80% confidence</code></pre>
  
  <p>It seems superfluous to put <code>F1</code>'s itemsets in here as they will all have a confidence of 100% regardless and don't actually "associate" anything, which is the reason I am now questioning whether <code>F1</code> are indeed "frequent"?</p>