Apriori关联规则算法的C语言实现

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

13120111大连民族学院学报JournalofDalianNationalitiesUniversityVo.l13,No.1January2011:2010-09-07;:2010-09-17:(20873055):(1977-),,,,:1009-315X(2011)01-0052-04AprioriC李楠a,宁燕子b,杨存志c(辽宁师范大学a.计算机与信息技术学院;b.档案馆;c.教务处,辽宁大连116029):Apriori,C,,:;;Apriori;C:TP312:AResearchandImplementationofAprioriRulesAlgorithmBasedonCLINana,NINGYan-zib,YANGCun-zhic(a.CollegeofComputerandInformationTechnology;b.Archives;c.AcademicAffairsDivisionLiaoningNormalUniversity,DalianLiaoning116029,China)Abstract:Associationruleisaneffectivewayforknowledgediscoveryindatamining,whereinalgorithms.TheAprioriisaclassicalalgorithm.BasedontheanalysisofthealgorithmAprior,iweintroducedthealgorithmsrealizationofdiscoveryoffrequentitemsetsandgenerationofassociationrulesbyusingC,andatlastitperformsavalidationtodiscoverthefrequentitemsetsfromthetraditionalmarketbaske,tandalsotherulessatisfyingwiththeminimumsupportandconfidence.Whichprovideasolidfoundationforfurtherresearchofassociationrules.Keywords:datamining;associationrules;Apriorialgorithm;Clanuage(DataMining,DM),[1],(KnowledgeDiscoveryinDatabase,KDD),KDD[2]:,,Agrawal1993[3],:I={i1,i2,,im}m,TI,DX!Y,XI,YI,X∀Y=,XY,:Support(X!Y)=|{T:X#YT,T∃D}|/|D|,XDY,:Confidence(X!Y)=|{T:X#YT,T∃D}|/|{T:XT,T∃D}|Dmin-supportmin-confidence:(1)min-support;(2),min-confidence,(1)Apriori,,,Apriori[4-7]1Apriori,Apriori,Apriori,Ck-1D,,Lk-1;Lk-1Ck,CkLk,,::D;min_sup:LL1={large1-itemsets};//min_sup1-for(k=2;Lk-1¹k++)dobeginCk=apriori_gen(Lk-1);//Ckk,foralltransactionst∃DdobeginCt=subset(Ck,t);//Cttforallcandidatesc∃Ctdoc.count++;endLk={c∃Ck|c.count%min_sup}endAnswer=#kLk;apriori-gen(Lk-1),(k-1)-k-:(k-1)-Lk-1:k-Ckforallitemsetp∃Lk-1doforallitemsetq∃Lk-1doifp.item1=q.item1,p.item2=q.item2,p.itemk-2=q.itemk-2,p.itemk-1q.itemk-1thenbeginc=p&q;//qk-1pifhas_infrequent_subset(c,Lk-1)thendeletec;//elseaddctoCk;endreturnCk;has_infrequent_subset(c,Lk-1)():k-c,(k-1)-Lk-1:cforall(k-1)-subsetsofcdoifS∃Lk-1thenreturnfalse;returntrue;has_infrequent_subset(c,Lk-1)ck-Agrawal,,,L2={AB,AD,AC,BD},ABCC3,BCL2,ABDC3,2-L222.111Apriori2.2C,,typedefstruct{531,:AprioriCintitem[10];}D_Node;typedefstruct{intitem[10];//item[0]}C_Node;//typedefstruct{intitem[10];//item[0]}L_Node;//2.3:voidmain(){int,in;intk;for(k=1;k1000;k++){n=1;InPut();C1();//,C1L1();//L1while(L[n][0].item[0]!=0){n+=1;Ln(n);//Ln(n)n}for(i=1;i=n;i++)OutPut(i);}}C1(),Cn()(n),L1(),Ln(),C1()L1()voidC1(){int,i,jk;intno=1,temp=0;C[1][0].item[0]=0;//1,,C[n][k].item[0]Cnkif(D[0].item[0]!=0){C[1][1].item[1]=D[1].item[1];}for(i=1;i=D[0].item[0];i++)//for1{for(j=1;j=D[i].item[0];j++)//for2{temp=1;for(k=1;k=no;k++)//for3{if(C[1][k].item[1]==D[i].item[j]){C[1][k].item[0]++;//temp=0;}//if}//endfor3if(temp)//{C[1][++no].item[1]=D[i].item[j];C[1][no].item[0]=1;}}//endfor2}//endfor1C[1][0].item[0]=no;//}//endofC1()voidL1(){int,i,jk;j=0;L[1][0].item[0]=0;for(i=1;i=C[1][0].item[0];i++){if(C[1][i].item[0]=min_supp)//if1{j+=1;for(k=1;k=1;k++)L[1][j].item[k]=C[1][i].item[k];L[1][j].item[0]=C[1][i].item54大连民族学院学报13[0];}}//endfor1L[1][0].item[0]=;j}//endofL1()2.42TIDIDT100I1,I2,I5T200I2,I14T300I2,I3T400I1,T2,I4T500I1,I3T600I2,I3T700I1,I3T800I1,I2,I3,I5T900I1,I2,I32,,,,,,3333Apriori,,Apriori:(1),I/Ok,CkLk10,10(2)Lk-1k-Ck,C,,,,,3Apriori,Apriori,C,:[1].[M].:,2002.[2],,,.[M].:,2005.[3]AGRAWALR,IMILIENSKIT,SWAMIA.Miningassociationrulesbetweensetsofitemsinlargedatasets[C].GIGMOD,1993:207-216.[4],.Apriori[J].,2007(43):24.[5],,.Apriori[J].,2006,23(2):44-46.[6].Apriori[J].,2006,23(3):78-82.[7],,.Apriori[J].,2006,16(3):58-60.(责任编辑刘敏)551,:AprioriC

1 / 4
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功