版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、數(shù)據(jù)挖掘課程設(shè)計報告題目關(guān)聯(lián)規(guī)則挖掘系統(tǒng)姓 名:XXXXXX班級:計算機0901學(xué) 號:XXXXXXXXXXX2013 年 6 月 19 日一、設(shè)計目的該程序?qū)崿F(xiàn)了對簡單數(shù)據(jù)進行頻繁項集挖掘的功能,主要使用Apriori算法,即使用候選產(chǎn)生發(fā)現(xiàn)頻繁項集。通過這次編程增強編程能力。二、設(shè)計要求實現(xiàn)數(shù)據(jù)挖掘的關(guān)聯(lián)規(guī)則,能夠挖掘數(shù)據(jù)之間的關(guān)聯(lián)信息,能夠讀取文件中的 數(shù)據(jù),能夠保存分析結(jié)果。界面友好。三、設(shè)計實現(xiàn)流程圖:Liifi罐舟卞境lit*BLrBv比命“ Z 11'| J 1 4k喘/P*! G*四、實現(xiàn)環(huán)境操作系統(tǒng)WindowsXP開發(fā)環(huán)境Netbeans7.1運行環(huán)境 Window
2、s系列操作系統(tǒng)(裝有Java運行時環(huán)境)五、實現(xiàn)結(jié)果完整輸出結(jié)果:run :顧客1 商品A 商品B 商品C 顧客2 商品A 商品B 顧客3 商品B 商品C 顧客4 商品C 商品B 商品1*候選集1:商品A商品B商品C頻繁集1:商品A商品B商品C*候選集2:商品A,商品B商品A,商品C商品B,商品C頻繁集2:商品A,商品B商品B,商品C*候選集3:商品A,商品B,商品C頻繁集3:*最大頻繁集:商品A,商品B商品B,商品C*關(guān)聯(lián)規(guī)則:商品 A=商品B1.0商品 B=商品A0.6666666666666666商品 B=商品C0.6666666666666666商品 C=商品B1.0六、設(shè)計小結(jié)這學(xué)期
3、學(xué)的數(shù)據(jù)挖掘課程豐富了我的知識面,讓我看到了信息技術(shù) 的巨大生命力和前景。數(shù)據(jù)挖掘涉及多學(xué)科技術(shù)的集成,包括數(shù)據(jù)庫和數(shù)據(jù)倉庫 技術(shù)、統(tǒng)計學(xué)、機器學(xué)習(xí)、高性能計算、模式識別、神經(jīng)網(wǎng)絡(luò)、數(shù)據(jù)可視化、信 息檢索等技術(shù)。通過數(shù)據(jù)挖掘,可以從數(shù)據(jù)庫提取有趣的知識、規(guī)律或高層信息, 并可以從不同角度觀察或瀏覽它們, 發(fā)現(xiàn)的知識可以用于做決策、 過程控制、信 息管理、查詢處理。利用數(shù)據(jù)挖掘技術(shù)可以幫助獲得決策所需的多種知識。在許多情況下,用戶并不知道數(shù)據(jù)存在哪些有價值的信息知識,因此對于一個數(shù)據(jù)挖掘系統(tǒng)而言,它應(yīng)該能夠同時搜索發(fā)現(xiàn)多種模式的知識, 以滿足用戶的期望和實 際需要。此外數(shù)據(jù)挖掘系統(tǒng)還應(yīng)能夠挖掘出
4、多種層次(抽象水平)的模式知識。 數(shù)據(jù)挖掘系統(tǒng)還應(yīng)容許用戶指導(dǎo)挖掘搜索有價值的模式知識。通過這次實踐,我對數(shù)據(jù)挖掘技術(shù)有了一個整體的認(rèn)識。同樣在編寫程序的時 候也遇到了這樣或那樣的問題。但在老師及同學(xué)們的幫助下,艱難的完成了這個 系統(tǒng)。這讓我對數(shù)據(jù)挖掘技術(shù)以后的深入學(xué)習(xí)打下了良好的基礎(chǔ)。同時我的編程能力進一步提高,Java方面的實戰(zhàn)經(jīng)驗進一步豐富。優(yōu)秀的設(shè)計要付諸實踐, 用戶需要的是真真實實的產(chǎn)品,知識轉(zhuǎn)化為產(chǎn)品,才能體現(xiàn)它的價值。附錄:主要代碼1、APPF.Java/* To cha nge this template, choose Tools | Templates* and open
5、the template in the editor.*/package datam ining;* author Admi ni strator*/public class APPF exte nds javax.sw in g.JFrame /* Creates new form APPF*/public APPF() in itComp onen ts();This method is called from within the con structor to in itialize the form.WARNING: Do NOT modify this code. The cont
6、en t of this method isalways* regenerated by the Form Editor.*/SuppressWar nin gs(" un checked")/ veditor-fold defaultstate="collapsed" desc="Ge nerated Code">private void in itComp onen ts() jScrollPa ne1 = new javax.sw in g.JScrollPa ne(); jTablel = new javax.swi n
7、g.J Table();jLabell = new javax.swi ng.J Label(); jTextFieldl = new javax.sw in g.JTextField();jLabel2 = new javax.sw in g.JLabel(); jTextField2 = new javax.sw in g.JTextField();jLabel3 = new javax.sw in g.JLabel(); jTextField3 = new javax.sw in g.JTextField();jButt on1 = new javax.swi ng.J Butt on(
8、); jScrollPa ne2 = new javax.sw in g.JScrollPa ne(); jTextAreal = new javax.sw in g.JTextArea();jLabel4 = new javax.sw in g.JLabel();jLabel5 = new javax.sw in g.JLabel();setDefaultCloseOperati on( javax.swi ng.Wi ndowC on sta n ts.EXIT_ON_CLOSE);new Object n ull, null.n ull, null,n ull, null,n ull,
9、null,n ull, null,n ull, null,n ull, null,n ull, null,n ull, null,null, null,new String "序列","項目");jScrollPa nel.setViewportView(jTablel);jLabel1.setText("支持度:");jLabel3.setText("挖掘深度:");jButton1.setText(”開始分析");evt)jButt on 1Act ion Performed(evt););jText
10、Areal.setColum ns(20);jTextArea1.setRows(5);jScrollPa ne2.setViewportView(jTextArea1);(”新宋體",0, 36); / NOI18NjLabel4.setText("數(shù)據(jù)挖掘");jLabel5.setText("置信度:");javax.sw in g.GroupLayoutgetC onten tPa ne().setLayout(layout);layout.setHorizo ntalGroup(layout=newjavax.swi ng.Group
11、Layout(getCo nten tPa ne();layout.createParallelGrou p(javax.sw in g.GroupLayout .Alig nmen t.LEADING) .addGroup(layout.createSeque ntialGroup().addG ap(33, 33, 33).addGroup(layout.createParallelGroup(javax.swi ng.GroupLayout.Alig nmen t.LEADING).addComp onen t(jScrollPa ne2)ING,layout.createSeque n
12、tialGroup().addGroup(layout.createParallelGroup(javax.sw.LEADING, false).addGroup(layout.createSeque ntialGroup().addComp onen t(jLabel1).addPreferredGap(javax.swi ng丄 ayoutStyle.Comp onen tPlaceme nt.RELATED,EFAULT_SIZE,Short.MAX_VALUE).addComp onen t(jTextField1,REFERRED_SIZE,67,REFERRED_SIZE)nt.T
13、RAILING,layout.createSeque ntialGroup().addComp onen t(jLabel3).addG ap(41,41,41).addComp onen t(jTextField3,REFERRED_SIZE,67,REFERRED_SIZE)nt.TRAILING,layout.createSeque ntialGr oup().addComp onen t(jLabel5).addPreferredGap(javax.swi ng丄 ayoutStyle.Comp onen tPlaceme nt.RELATED,EFAULT_SIZE,Short.MA
14、X_VALUE).addGroup(layout.createParallelGroup(lig nmen t.LEADING) .addComp onen t(jLabel2,lig nmen t.TRAILING).addComp onen t(jTextField2,.addPreferredGap(javax.swi ng丄 ayoutStyle.Componen tPlaceme nt.RELATED,40, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.sw.addGroup(layout.createSeq
15、ue ntialGroup().addComp onen t(jButt onl).addG ap(69, 69, 69).addComp onen t(jScrollPa ne1,.addC on tai nerGap()nt.TRAILING, layout.createSeque ntialGr oup().addComp onen t(jLabel4,.addG ap(130, 130, 130);layout.setVerticalGroup(layout.createParallelGrou p(javax.sw in g.GroupLayout .Alig nmen t.LEAD
16、ING).addGroup(layout.createSeque ntialGroup().addC on tai nerGap().addComp onen t(jLabel4,REFERRED_SIZE,83,REFERRED_SIZE).addGroup(layout.createParallelGroup(javax.swi ng.GroupLayout.Alig nmen t.LEADING ).addGroup(layout.createSeque ntialGroup().addGap(34, 34, 34).addGroup(layout.createParallelGroup
17、(javax.sw.BASELINE).addComp onen t(jLabel1).addComp onen t(jTextField1,REFERRED_SIZE,EFAULT_SIZE,REFERRED_SIZE).addGap(24, 24, 24).addGroup(layout.createParallelGroup(javax.sw.BASELINE).addComp onen t(jLabel2).addComp onen t(jTextField2,REFERRED_SIZE,EFAULT_SIZE,REFERRED_SIZE).addComp onen t(jLabel5
18、).addComp onen t(jButt on 1).addGap(25, 25, 25).addGroup(layout.createParallelGroup(javax.sw.BASELINE).addComp onen t(jTextField3,REFERRED_SIZE,EFAULT_SIZE,REFERRED_SIZE).addComp onen t(jLabel3,REFERRED_SIZE,15,.addGroup(layout.createSeque ntialGroup().addPreferredGap(javax.swi ng丄 ayoutStyle.Compon
19、en tPlaceme nt.RELATED) .addComp onen t(jScrollPa ne1,.addG ap(18, 18, 18).addComp onen t(jScrollPa ne2,EFAULT_SIZE,167,Short.MAX_VALUE);pack();/ </editor-fold>evt) DBMa nager db = new DBMa nager();Tran sactio nCon tai nerApriori apriori = new Apriori();/設(shè)置參數(shù)doubleapriori.setM in Support(suppo
20、rt);doubleapriori.setMi nCon fide nce(co nfide nee);tran sact ionContainerdb.getTra nsactio nCon tai ne r(jTablel);supportDouble.parseDouble(jTextF ield1.getText();con fide neeDouble.parseDouble(jTextField2.getText();int deep = In teger.parse In t(jTextField3.getText();即riori.setDeep(deep); /設(shè)置最大挖掘深
21、度,否則直到不產(chǎn)生新頻繁集而自動停止apriori.setCo ntain er(tra nsact ionContain er);/進行分析apriori.a nalyse();/打印信息Stri ng info = apriori.pri ntIn fo();jTextAreal.appe nd(i nfo);/* param args the comma nd line argume nts*/public static void main( Stri ng args) /* Set the Nimbus look and feel*/<editor-fold defaultsta
22、te="collapsed" desc=" Look and feelsett ing code (optio nal) ">/* If Nimbus (introduced in Java SE6) is not available, stay withthe* default look and feel. For details see*/try for(javax.swi ng.UIMa nager.LookA ndFeell nfoinfojavax.swi ng.UIMa nager.get In stalledLookA ndFeels
23、() if ("Nimbus".equals(i nfo.getName() javax.swi ng.UIMa nager.set LookA ndFeel( in fo.getClass Name();break; catch (ClassNotF oun dExcepti on ex) catch (In sta ntiatio nExcepti on ex) ex); catch (IllegalAccessExcepti on ex) ex); catch (javax.sw in g.U nsupportedLookA ndFeelExcepti on ex)
24、ex);v/editor-fold>/* Create and display the form*/public void run() new APPF().setVisible(true););2、Apriori.java:private javax.swi ng.J Butt on jButt on1;private javax.swi ng.J Label jLabell;private javax.swi ng.J Label jLabel2;private javax.swi ng.J Label jLabel3;private javax.swi ng.J Label jLa
25、bel4;private javax.swi ng.J Label jLabel5;private javax.sw in g.JScrollPa ne jScrollPa nel;private javax.sw in g.JScrollPa ne jScrollPa ne2;static javax.swi ng.J Table jTable1;static javax.sw in g.JTextArea jTextArea1;private javax.sw in g.JTextField jTextField1;private javax.sw in g.JTextField jTex
26、tField2;private javax.sw in g.JTextField jTextField3;/ End of variables declarati onpackage datam ining;public class Apriori private double min Support; /最小支持度private double minCon fide nee; /最小置信度private Map container; /交易數(shù)據(jù)容器private int totalSize; /樣品數(shù)據(jù)條數(shù)private List can ditateSetList = new ArrayL
27、ist(); /private List freque ntSetList = new ArrayList(); /private List maxFreque ntSetList = new ArrayList(); /候選集鏈表頻繁集鏈表最大頻繁集private int maxDeep = -1;private int curDeep = 0;private boolea n isStop = false;private Set eleme ntSet = new TreeSet();private List ruleList = new ArrayList();/設(shè)置挖掘深度,如果為-1
28、,表明直到不產(chǎn)生新的頻繁集才停止挖掘public void setDeep(i nt k) this.maxDeep = k;private double getM inCon fide nce() return minCon fide nee;public void setM inCon fide nce(double minCon fide nee) this.mi nCon fide nce = mi nCon fide nee;private double getM in Support() retur n min Support;public void setM in Support
29、(double min Support) this. min Support = min Support;private Map getC ontainer() retur n container;public void setC on tai ner(Tra nsactio nCon tai nertran sact ionContainer)this.co ntai ner = tran sact ionCon tain er.getCo ntain er();this.totalSize = this.con tai ner.size();private boolea n isStop(
30、) retur n this.isStop | (maxDeep > 0 && curDeep = maxDeep);private void stopA nalyse() this.isStop = true;/*根據(jù)最小支持度,最小自信度,樣品數(shù)據(jù) 進行數(shù)據(jù)分析*/public void an alyse() /計算候選集、頻繁集this.makeCa nditateSet1();this.makeFreque ntSet1();while (!isStop() this.curDeep+; /深度 +1創(chuàng)建候選集this.makeCa nditateSet(); /
31、創(chuàng)建頻繁集this.makeFreque ntSet(); / / 計算最大頻繁集this.makeMaxFreque ntSet();/計算規(guī)則this.makeRules();/*創(chuàng)建規(guī)則*/private void makeRules() int ruleNum = 0;for (Object form : this.maxFreque ntSetList) Tran sact ionForm tf = (Tran sactio nF orm) form; ruleNum = (1 << tf.getltems().size() - 2;for (i nt i = 1; i
32、<= ruleNum; i+) Rule rule = new Rule();Tran sacti onForm A = new Tran sact ionFo rm();Tran sacti onForm B = new Tran sact ionFo rm(); int j = 0;Set items = tf.getItems();for (Object object : items) String item = (String) object;if (1 << j) & i) != 0) A. addltem(item); else B. addltem(it
33、em);j+;Tran sacti onForm AB = new Tran sact ionForm();AB.addAII(A.getltems();AB.addAII(B.getltems();if(getSupportNum(AB) >= (getSupportNum(A)minCon fide nee) double confidence = this.getSupportNum(AB) * 1.0 / this.getSupportNum(A);ruIe.setA(A);ruIe.setB(B);ruIe.setC on fide nce(con fide nee);/* 計
34、算1項候選集*/ private void makeCa nditateSet1() Set keySet = con tai ner.keySet();Iterator keyiterator = keySet.iterator();Stri ng TID;Tran sacti onForm tran sact ionForm;List list = new ArrayList(); /存放 1 項候選集Set item1 = new TreeSet();while (keylterator.hasNext() TID = (Stri ng) keyIterator. next();tran
35、sactionForm = (TransactionForm) (container.get(TID);Set items = tran sact ionFo rm.getItems();for (Object object : items) item1.add(object);eleme ntSet.addAII(item1);for (Object object : item1) Tran sact ionForm tf = new Tran sact ionFo rm();tf.addItem(object);list.add(tf);this.ca nditateSetList.add
36、(list);this.curDeep = 1;/*計算k項候選集*/ private void makeCa nditateSet() /讀取前一個頻繁集Listfron tFreque ntSetList=(List)this.freque ntSetList.get( this.curDeep - 2);List n ewCa nditateList = new ArrayList();for (Object obj : frontFrequentSetList) Tran sact ionForm tf = (Tra nsacti onForm) obj;for (Object ite
37、m : this.elementSet) Set items = new TreeSet();items.addAII(tf.getltems();items.add(item);if (items.size() != this.curDeep) con ti nue;Tran sacti onFormn ewTra nsacti onForm= newTran sactio nF orm();n ewTra nsactio nF orm.setItems(items);if (this.getSupportNum( newTra nsactio nF orm) != 0) if(!isExi
38、t (n ewCa nditateList,n ewTra nsactio nF orm)n ewCa nditateList.add( newTra nsactio nF orm);this.ca nditateSetList.add( newCa nditateList);/*判斷鏈表中是否存在相同的交易表單*/private boolea n isExit(List list, Tran sactio nF orm n ewForm) for (Object form : list) Set curSet = (Tra nsactio nF orm) form).getltems();S
39、et n ewSet = n ewForm.getltems();Set tempSet = new TreeSet(); tempSet.addAII(curSet);int beg in Size = tempSet.size(); tempSet.addAll( newSet);int en dSize = tempSet.size();if (en dSize <= beg in Size) /只要有一個集合沒變大,說明已存在return true;return false;/*創(chuàng)建最大頻繁集*/private void makeMaxFreque ntSet() for (in
40、t i = freque ntSetList.size() - 1; i >= 0; i-) List list = (List) freque ntSetList.get(i);for (Object form : list) if(!isExit(maxFreque ntSetList,(Tran sactio nF orm)form) this.maxFreque ntSetList.add(form);/*創(chuàng)建頻繁集*/private void makeFreque ntSet() List freque ntList = new ArrayList();Listcan dita
41、teList=(List)this.ca nditateSetList.get (this.curDeep - 1);for (Object form : can ditateList) Tran sact ionForm tf = (Tran sactio nF orm) form;if (this.getSupportNum(tf) >= min Support * totalSize) freque ntList.add(tf);this.freque ntSetList.add(freque ntList);if (freque ntList.size() = 0) this.s
42、topAnalyse(); /如果沒有新的頻繁集,則可停止分析/*創(chuàng)建頻繁1項集*/ private void makeFreque ntSet1() List canditateList = (List) canditateSetList.get(O);List freque ntList = new ArrayList();for (Object object : canditateList) Tran sact ionForm tf = (Tran sactio nF orm) object;if (this.getSupportNum(tf) >= min Support * t
43、otalSize) freque ntList.add(tf);this.freque ntSetList.add(freque ntList);if (freque ntList.size() = 0) this.stopAnalyse(); /如果沒有新的頻繁集,則可停止分析/*計算支持?jǐn)?shù)樣品清單對newForm的支持?jǐn)?shù)*/ private int getSupportNum(Tra nsactio nF orm n ewForm) int coun ter = 0;Set keySet = con tai ner.keySet();Iterator keyiterator = keySe
44、t.iterator();Stri ng TID;Tran sacti onForm tran sact ionForm;while (keylterator.hasNext() /該循環(huán)不可以跳出,一定要執(zhí)行到結(jié)束TID = (Stri ng) keyIterator. next();tran sact ionForm= (Tran sactio nF orm)con tai ner.get(TID);/樣品中的某一清單Iterator items = tran sact ionFo rm.getltems().iterator();Iterator n ewItems = n ewForm
45、.getltems().iterator();boolea n isMatch = true;while (n ewltems.hasNext() /配置新清單中的所有項String newItem = (String) newItems.next();boolean findItem = false;while (items.hasNext() String item = (String) items.next();if (newltem.equals(item) fin dltem = true;break;if (!fin dltem) isMatch = false;break;if
46、(isMatch) coun ter+;retur n coun ter;/*打印分析結(jié)果信息*/public String prin tl nfo() for (int i = 0; i < this.curDeep; i+) List list = (List) this.ca nditateSetList.get(i);if (list.size() = 0) con ti nue;(”候選集"+ (i + 1) + ":");in fo+="候選集"+ (i + 1) + ":"for (Object obje
47、ct : list) (Tran sactio nF orm)Tran sacti onFormtran sacti onFormobject;Set items = tran sactio nF orm.getltems();Strin gBuffer sb = new Stri ngBuffer("");for (Object item : items) sb.appe nd(item).appe nd(",");sb.setCharAt(sb.length() - 1,'');+ "");in fo+=sb +
48、"" list = (List) this.freque ntSetList.get(i);頻繁集"+ (i + 1) + ":");in fo+="n頻繁集"+ (i + 1) + ":"for (Object object : list) Tran sacti onFormtran sacti onForm= (Tra nsacti onForm)object;Set items = tran sactio nF orm.getltems();Strin gBuffer sb = new Stri n
49、gBuffer("");for (Object item : items) sb.appe nd(item).appe nd(",");sb.setCharAt(sb.length() - 1,'');+ "");in fo+=sb + ""*System.out.pri ntl n("n);in fo+="n*n"System.out.pri nt(”最大頻繁集:");*info+="最大頻繁集:";for (Object object : th
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年度企業(yè)員工績效評估與薪酬調(diào)整合作合同3篇
- 2024年企事業(yè)單位綠植擺放與養(yǎng)護管理服務(wù)合同3篇
- 2024年某餐飲企業(yè)與食材供應(yīng)商之間的食材采購合同
- 2024年幕墻腳手架施工分包質(zhì)量檢測及整改合同3篇
- 2024年度淘寶電商團隊管理與領(lǐng)導(dǎo)力培訓(xùn)服務(wù)協(xié)議3篇
- 2024年商鋪租賃合同模板:市中心黃金地段商鋪租賃管理規(guī)范2篇
- 建筑物拆除爆破工程合約
- 食品加工攪拌機租賃合同
- 企業(yè)員工績效承諾書樣版
- 企業(yè)用工信息化管理策略
- 機電安裝工操作規(guī)程
- 2023年現(xiàn)場管理與改善手法
- 心跳驟停后目標(biāo)體溫管理
- 數(shù)獨-九宮格學(xué)習(xí)資料課件
- 市場調(diào)研員工作流程圖
- 生態(tài)毒理學(xué)-山西大學(xué)中國大學(xué)mooc課后章節(jié)答案期末考試題庫2023年
- 動畫分鏡頭腳本文檔模板
- 大事記編寫規(guī)范
- 當(dāng)代大學(xué)生國家安全教育學(xué)習(xí)通課后章節(jié)答案期末考試題庫2023年
- 外立面泛光照明施工方案
- 住院患者非計劃拔管危險因素評估量表
評論
0/150
提交評論