evandempsey / fp-growth

Python implementation of the Frequent Pattern Growth algorithm
ISC License
136 stars 55 forks source link

Different rules on regenerating #14

Open ashishkg0022 opened 5 years ago

ashishkg0022 commented 5 years ago

I get different rules, each time I run the code.


transaction = [['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14',\
 '15', '16', '7', '17', '18', '19', '20', '21', '7', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '29', '30'], ['32', '33'],\ 
['34', '34', '34', '34', '34', '34', '34', '34', '35', '35', '36', '36', '34', '34', '37', '37', '37', '37',\
 '37', '37', '34', '34', '29', '30', '36', '36', '36', '36', '36', '36']]

import pyfpgrowth as fg
patterns = fg.find_frequent_patterns(transaction, 3)
rules = fg.generate_association_rules(patterns, 0.1)

Can anyone see it ?

Rbain2 commented 5 years ago

Ran this code three times and rules always are consistent as below (('37',), 1.25)

(('30',), 1.5) (('34',), 1.0) (('30',), 1.0) (('30',), 1.0) ((), 0.2916666666666667) (('37',), 0.15625) (('37',), 6.0) (('36',), 1.0) ((), 0.3125) (('36',), 0.20833333333333334) (('29',), 1.0) (('30',), 1.0) (('29',), 1.0) ((), 1.0) ((), 0.3125) (('30',), 1.5) (('30',), 1.0) (('30',), 1.0) (('37',), 6.0) (('36',), 1.0) (('36',), 1.0) (('37',), 6.0) (('34',), 2.5) (('36',), 1.0) (('34',), 12.0) (('37',), 6.0) ((), 0.20833333333333334) (('34',), 1.0) (('34',), 12.0) (('29', '30'), 1.0) (('30',), 1.0) (('30',), 1.0) (('30',), 0.3125) (('30',), 1.0) (('34',), 1.0) (('34',), 1.0) ((), 0.3125) (('36',), 1.0) (('36',), 8.0) ((), 0.20833333333333334) (('34',), 12.0) (('30',), 2.0) (('30', '34'), 1.0) (('30',), 2.0) (('29',), 1.0) (('29',), 1.5) (('34',), 1.0) (('30',), 1.0) ((), 1.0) (('37',), 0.15625) (('29', '34'), 1.0) ((), 0.3125) (('30',), 1.0) (('29',), 1.0) (('36', '37'), 1.25) (('30', '37'), 6.0) ((), 0.3125) (('29',), 1.0) (('30', '36'), 1.0)

ashishkg0022 commented 5 years ago

I am running it on python3. Are you using python2 or python3 ?

Rbain2 commented 5 years ago

I am using python 2.7

ashishkg0022 commented 5 years ago

The issue may be with python 3.