11-3-FP-growth-demo.py 397 B

12345678910111213141516171819202122
  1. import pyfpgrowth
  2. def main():
  3. datasets = [
  4. [1, 2, 5],
  5. [2, 4],
  6. [2, 3],
  7. [1, 2, 4],
  8. [1, 3],
  9. [2, 3],
  10. [1, 3],
  11. [1, 2, 3, 5],
  12. [1, 2, 3]
  13. ]
  14. patterns = pyfpgrowth.find_frequent_patterns(datasets, 2)
  15. rules = pyfpgrowth.generate_association_rules(patterns, 0.7)
  16. print(rules)
  17. if __name__ == '__main__':
  18. main()