ymoch / apyori

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

Sort the rules found by confidence #33

Closed rmenoli closed 6 years ago

rmenoli commented 6 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 6 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'))