pls i want to know how to get the absolute support and relative support of itemsets in python. presently i have the following: import pandas as pd import pyfpgrowth from mlxtend.preprocessing import TransactionEncoder from mlxtend.frequent_patterns import apriori from collections import Counter
dataset = [['a', 'b', 'c', 'd'],
['b', 'c', 'e', 'f'],
['a', 'd', 'e', 'f'],
['a', 'e', 'f'],
['b', 'd', 'f']
]
te = TransactionEncoder()
te_ary = te.fit(dataset).transform(dataset)
df = pd.DataFrame(te_ary, columns=te.columns_)
print (df)
#print support
print(apriori(df, min_support = 0.0))
#print frequent itemset
frequent_itemsets = apriori(df, min_support=0.6, use_colnames=True)
frequent_itemsets['length'] = frequent_itemsets['itemsets'].apply(lambda x:
len(x))
frequent_itemsets
print ("frequent itemset at min support = 0.6")
print(frequent_itemsets)
but i do not know how to return the absolute support and relative support.
pls help me out
Aucun commentaire:
Enregistrer un commentaire