Note that there are some explanatory texts on larger screens.

plurals
  1. POHow could we know the ColumnName /attribute of items generated in Rules
    text
    copied!<p>Using arules package, 'apriori' returns a 'rules' object.</p> <p>How can we make a query that - What exact column does the item(s) in rules {lhs, rhs} come from ?</p> <p>Example: <br><br> I've some data in a tabular manner in file "input.csv" and want to associate/interpret the returned rule itemsets with the column headers in the file. How can I possibly do that?</p> <p>Any pointers are appreciated. Thanks,</p> <p><br><br> <strong>A reproducible example:</strong> <br> <code>input.csv</code></p> <pre><code>ABC,DEF,GHI,JKL,MNO 11,56789,1,0,10 12,57685,0,0,10 11,56789,0,1,11 10,57689,1,0,12 11,56789,0,1,12 10,57685,1,0,12 10,57689,1,0,10 11,56789,0,1,12 11,56789,0,0,10 11,56789,0,0,10 11,56789,0,1,10 11,56789,0,0,10 </code></pre> <p>Call to Apriori :</p> <pre><code>transactions &lt;- read.transactions("input.csv", format="basket", sep = ',', cols = NULL, rm.duplicates = TRUE) Rules &lt;- apriori(transactions, parameter = list(supp = 0.45, conf = 0.50, target = "rules")) </code></pre> <p>Returned result: <br></p> <pre><code>&gt; inspect(Rules) lhs rhs support confidence lift 1 {} =&gt; {11} 0.6153846 0.6153846 1.000000 2 {} =&gt; {56789} 0.6153846 0.6153846 1.000000 3 {} =&gt; {1} 0.6153846 0.6153846 1.000000 4 {} =&gt; {10} 0.6923077 0.6923077 1.000000 5 {} =&gt; {0} 0.9230769 0.9230769 1.000000 6 {11} =&gt; {56789} 0.6153846 1.0000000 1.625000 7 {56789} =&gt; {11} 0.6153846 1.0000000 1.625000 8 {11} =&gt; {0} 0.6153846 1.0000000 1.083333 9 {0} =&gt; {11} 0.6153846 0.6666667 1.083333 10 {56789} =&gt; {0} 0.6153846 1.0000000 1.083333 11 {0} =&gt; {56789} 0.6153846 0.6666667 1.083333 12 {1} =&gt; {0} 0.6153846 1.0000000 1.083333 13 {0} =&gt; {1} 0.6153846 0.6666667 1.083333 14 {10} =&gt; {0} 0.6923077 1.0000000 1.083333 15 {0} =&gt; {10} 0.6923077 0.7500000 1.083333 16 {11, 56789} =&gt; {0} 0.6153846 1.0000000 1.083333 17 {0, 11} =&gt; {56789} 0.6153846 1.0000000 1.625000 18 {0, 56789} =&gt; {11} 0.6153846 1.0000000 1.625000 </code></pre> <p>Now, I want to make a distinction between the items of say, rule No.13</p> <p><code>13 {0} =&gt; {1} 0.6153846 0.6666667 1.083333</code></p> <p><code>{0} =&gt; {1}</code> means, a value of <code>0</code> in dimension <code>"GHI"</code> implies a value of <code>1</code> in <code>"JKL"</code> or vice versa ?</p> <p>so, Is there a way we can get the column name/id of the values of itemsets returned in rules object ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload