问题
I have a data frame of inputs which look like this
I generate association rules using pandas
frequent_itemsets = apriori(df, min_support=0.2, use_colnames=True)
rules = association_rules(frequent_itemsets, metric= "confidence", min_threshold = 0.6 )
My output only generates rules values of each itemset without labeling the header. It looks something like below. My questions are 1- I want to label the antecedent and consequents with their header name (Age, AL, Sex,...etc) because I can't differentiate between all the output numbers. Example:
Age = 20, Smoke = n => Chol = y
2- If I have the previous rule and I want to iterate on all rules in my output to do some calculations, how can I do this given the information in my output
来源:https://stackoverflow.com/questions/54900630/iterate-through-association-rules-using-the-header-of-an-itemset