Orange, Python: List Out of Range Association Rules - How Should Data Look?
I'm playing with the Orange Association Rules sample.
Orange Doc
My code is very similar to the docs:
import Orange
data = Orange.data.Table("order_data.basket")
rules = Orange.associate.AssociationRulesSparseInducer(data, support = 0.5)
print "%5s %5s" % ("supp", "conf")
for r in rules:
print "%5.3f %5.3f %s" % (r.support, r.confidence, r)
inducer = Orange.associate.AssociationRulesSparseInducer(support = 0.5, store_examples = True)
itemsets = inducer.get_itemsets(data)
# print itemsets
print [data.domain[i].name for i in itemsets[5][0]]
And it works with data from Orange
our, two, weapons, are, fear, and, surprise and ruthlessness,
our effectiveness , three, weapons, are, fear, surprise and ruthlessness, efficiency and, almost fanatical, devotion, to the Pope, ours
among ours, weapons
But with my data, I am getting an error:
supp conf
Traceback (most recent call last):
File "inqui.py", line 15, in <module>
print [data.domain[i].name for i in itemsets[5][0]]
IndexError: list index out of range
What's my data:
Item1
Item2, Item2, Item2, Item2, Item7, Item7, Item7, Item7, Item7
Item1, Item1, Item1, Item1, Item1, Item1, Item1, Item2
Item4, Item4
Item1, Item1, Item1, Item1, Item1, Item1, Item1, Item1, Item2
Item5
I checked for spaces and used a barebone / short version of my data with 10 lines like in the example, but I still get this error.
Where did it come from?
+3
source to share
No one has answered this question yet
Check out similar questions: