11-1-Apriori-demo.py 379 B

123456789101112131415
  1. from model import Apriori
  2. def main():
  3. # 生成测试样本
  4. data = [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]
  5. # apriori 算法
  6. apriori = Apriori()
  7. frequently_itemset, support_data = apriori.apriori(data, 0.5)
  8. rules = apriori.generate_rules(frequently_itemset, support_data, min_reliability=0.7)
  9. print(rules)
  10. if __name__ == '__main__':
  11. main()