supportData = {('ELF'): 0.75, ('CAT'): 0.75, ('BAT', 'CAT', 'ELF'): 0.5, ('ARK', 'BAT'): 0.25, ('ARK', 'ELF'): 0.25, ('CAT', 'ELF'): 0.5, ('DOG'): 0.25, ('BAT', 'CAT'): 0.5, ('BAT', 'ELF'): 0.75, ('ARK'): 0.5, ('ARK', 'CAT'): 0.5, ('BAT'): 0.75}
L = [('ARK'), ('CAT'), ('CAT'), ('ELF'),('ARK', 'CAT'), ('BAT', 'ELF'), ('BAT', 'CAT'), ('CAT', 'ELF'),('BAT', 'CAT', 'ELF')]
for freqSet in L:
H = list(freqSet)
if len(H) == 1:
pass
else:
for conseq in H:
freqsetlist = list(freqSet)
freqsetlist.remove(conseq)
if len(freqsetlist) == 1:
conf = supportData[freqSet]/supportData[tuple(freqsetlist)[0]]
if conf >= 0.1:
print freqsetlist,'-->',conseq,'conf:',conf
else:
conf = supportData[freqSet]/supportData[tuple(freqsetlist)[:]]
if conf >= 0.1:
print freqsetlist,'-->',conseq,'conf:',conf
Output
KeyError: ('R','K')
Can someone point out why I am getting this error? It seems the error occur when len(freqsetlist) is > 1. That is when calculating tuple with 3 element