Apriori and fp-growth implement of python
No Data
求star!求star!求star!
In this repository implemente 6 class of Association rule data mining algorithm
1.Apriori (apriori.py)
apriori algorithm
2.Aprioricompress(aprioricompress.py)
transaction compression processing for apriori algorithm
3.Apriorihash(apriorihash.py)
hash method for apriori algorithm
4.Aprioriplus(aprioriplus.py)
transaction compress + dataset compress+hash + apriori
5.Fpgrowth(fpgrowth.py)
fp-growth algorithm
6.Fpgrowthplus(fpgrowthplus.py)
dataset compress + fp_growth
git clone https://github.com/blackAndrechen/data_mine
into this folder
cd data_mine
write your own code,take apriori algorithm for example ``` from apriori import *
data=[[l1,l2,l3,l4], [l1,l3,l5], [l1,l3,l4]] minsupport=2 minconfident=0.6
apr=Apriori() rulelist=apr.generateR(data,minsupport,minconfident) ```
from fp_growth import * fp=Fp_growth() rule_list=fp.generate_R(data,min_support,min_confident)
groceries.csvand
药方.xlsdata file,you can try running it ``` filename="groceries.csv" minsupport=25 minconf=0.7
import os currentpath=os.getcwd() path=currentpath+"/dataset/"+filename
data=loaddata(path) apr=Apriori() rulelist=apr.generateR(data,minsupport,minconf)
- if you want use youself dataset,suggest you rewrite a function to read youself dataset,And make sure your data set looks like this.data=[[l1,l2,l3,l4], [l1,l3,l5], [l1,l3,l4]]
- if you want save the result of Association rule datasavepath=savepath=currentpath+"/log/"+filename.split(".")[0]+"_apriori.txt"
saverule(rulelist,save_path) ```
simple analyse of my dataset