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.