Need to find out if an 3-itemset list is a superset of at least one 2-itemset. Every 3-itemset that has a frequent size-2 subset is already in your list. The list does not contain duplicated sets.
This is the last code I tried. The output should be a small list of sets if there are any subsets/supersets. With this code though I seem to be getting a larger list instead of a smaller list. Edited...
itemset2 =[{'🌭', '🍔'}, {'🌭', '🍕'}, {'🍔', '🌮'}, {'🍕', '🌮'}, {'🍕', '🍔'}, {'🍔', '🍗'},
{'🍟', '🍔'}, {'🍦', '🍔'}, {'🍕', '🍗'}, {'🍟', '🍕'}, {'🍦', '🍕'}]
itemset3 =[{'🍧', '🍦', '🍗'}, {'🍌', '🍊', '🍇'}, {'🍭', '🍰', '🍟'}, {'🍰', '🍉', '🍇'},
{'🍦', '🍊', '🍓'}, {'🍩', '🍕', '🌮'}, {'🍦', '🍪', '🍗'}, {'🍧', '🍕', '🍔'}, {'🍕', '🍑', '🍗'},
{'🍏', '🍎', '🍬'}, {'🥝', '🍊', '🍬'}, {'🍧', '🍨', '🍰'}, {'🍦', '🍕', '🍑'}, {'🍖', '🥝', '🍇'},
{'🍋', '🍳', '🍊'}, {'🍪', '🍌', '🍓'}, {'🍧', '🍰', '🍎'}, {'🍟', '🍉', '🍔'}, {'🍦', '🍕', '🍬'},
{'🍭', '🍳', '🥓'}, {'🍏', '🍉', '🎂'}, {'🍟', '🍕', '🍉'}, {'🍊', '🍫', '🍍'}, {'🍋', '🍫', '🎂'},
{'🍦', '🍑', '🍔'}, {'🍦', '🍫', '🍬'}, {'🍑', '🍔', '🍗'}, {'🍊', '🍇', '🍓'}, {'🍳', '🍔', '🌮'}]
stuff = itemset2
final = [set(y) for y in {frozenset(x) for x in stuff}]
final
nostuff=itemset3
ablanklist=[]
ablanklist2=[]
blanklist=set()
for things in nostuff:
ablanklist.append(list(things))
for stuff in ablanklist:
for items in final:
if stuff[0] and stuff[1] in items:
print(items)
#print(final)
The condition is a simple application of any
.
Given a trio
element from three-itemset
if any(pair < trio for pair in two-itemset):
will tell you whether any pair is a subset of the given 3-element set.