Replies: 2 comments
-
Thanks for the comment. I am not sure if I am on the same page. (Haven't looked at the frequent pattern code in a while). So, fpgrowth should be returning frozensets via the dataframe column entries: from mlxtend.frequent_patterns import fpgrowth
import pandas as pd
from mlxtend.preprocessing import TransactionEncoder
dataset = [['Milk', 'Onion', 'Nutmeg', 'Kidney Beans', 'Eggs', 'Yogurt'],
['Dill', 'Onion', 'Nutmeg', 'Kidney Beans', 'Eggs', 'Yogurt'],
['Milk', 'Apple', 'Kidney Beans', 'Eggs'],
['Milk', 'Unicorn', 'Corn', 'Kidney Beans', 'Yogurt'],
['Corn', 'Onion', 'Onion', 'Kidney Beans', 'Ice cream', 'Eggs']]
te = TransactionEncoder()
te_ary = te.fit(dataset).transform(dataset)
df = pd.DataFrame(te_ary, columns=te.columns_)
df = fpgrowth(df, min_support=0.6, use_colnames=True)
The dataset columns are "support" and "itemset" So, I was wondering if you were perhaps referring to the from mlxtend.frequent_patterns import association_rules
df_2 = association_rules(df, metric="confidence", min_threshold=0.7)
So, I am wondering if there is a bug in your case maybe, or are you referring to how something is handled in the code internally (I haven't looked at the details in a while and would have to refresh my memory then) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It is the case that frozenset (an actual frozenset) is the type of the dataframe column being created by a unit test in https://github.com/rasbt/mlxtend/blob/master/mlxtend/frequent_patterns/tests/test_fpbase.py
However, str is the type in the dataframe column 'antecedent' being created by fpgrowth, not an actual frozenset. It is a actual string that looks like this example:
"frozenset({'CollegeBasketball', 'nfl'})"
For now, we have to first run eval() on such an antecedent str, in order to get an antecedent that is actually of type frozenset, for example:
eval("frozenset({'CollegeBasketball', 'nfl'})")
Instead, like the unit test, perhaps frozenset should also be the type that fpgrowth is creating.
What is your opinion?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions