Iterate through association rules using the header of an itemset

人盡茶涼 提交于 2019-12-24 11:23:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!