ymoch / apyori

A simple implementation of Apriori algorithm by Python.
MIT License
248 stars 93 forks source link

Sort the rules found by confidence #33

Closed rmenoli closed 7 years ago

rmenoli commented 7 years ago

Hi After I have found the rules with a minimum support and a minimum confidence, I would sort the rules found by confidence, is it possible?

It is the code that I wrote rules = list(apriori(dataset, min_support=0.003, min_confidence=0.3, min_lift=1.01)) Ty

rmenoli commented 7 years ago
def useattr(attr):
    def kicker(obj):
        tmp=getattr(obj, attr)
        return tmp [0][2]
    return kicker

rules = sorted(rules, key=useattr('ordered_statistics'))