title: SQL: Rule Mining from an Item set
body: <p>Hey mates I am trying to implement an association rule mining in a vertica db: So far I got the heavy lifting done by finding the frequent itemsets however I still need to generate the rules. Here is an example:</p>
  
  <p>Initial table:</p>
  
  <pre><code>+--------+-------+-------+
  | item1  | item2 | item3 |
  +--------+-------+-------+
  | A      | B     | C     |
  +--------+-------+-------+
  </code></pre>
  
  <p>With 3 items I can generate 6 rules, a rule has a rule body and a rule head. This would result in the following table:</p>
  
  <pre><code>+---------+---------+--------+--------+
  | ItemB1  | ItemB2  | ItemH1 | ItemH2 |
  +---------+---------+--------+--------+
  | A       | Null    | B      | C      |
  | B       | Null    | A      | C      |
  | C       | Null    | A      | B      |
  | A       | B       | C      | Null   |
  | A       | C       | B      | Null   |
  | B       | C       | A      | Null   |
  +---------+---------+--------+--------+
  </code></pre>
  
  <p>This is a very abstract example, in reality there is more than one item set and more than 3 items in one item set. I found some papers that discuss association rule mining and claim that this part is trivial. Guess not so trivial to me.</p>
  
  <p>Thanks</p>