FP增長(zhǎng)算法實(shí)驗(yàn)報(bào)告wx_第1頁(yè)
FP增長(zhǎng)算法實(shí)驗(yàn)報(bào)告wx_第2頁(yè)
FP增長(zhǎng)算法實(shí)驗(yàn)報(bào)告wx_第3頁(yè)
FP增長(zhǎng)算法實(shí)驗(yàn)報(bào)告wx_第4頁(yè)
FP增長(zhǎng)算法實(shí)驗(yàn)報(bào)告wx_第5頁(yè)
已閱讀5頁(yè),還剩4頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、fp增長(zhǎng)算法實(shí)驗(yàn)報(bào)告實(shí)驗(yàn)人:王城學(xué)號(hào):20101174實(shí)驗(yàn)?zāi)康牧私怅P(guān)聯(lián)規(guī)則在數(shù)據(jù)挖掘中的應(yīng)用,理解和掌握關(guān)聯(lián)挖掘的經(jīng)典算法fp增長(zhǎng) 算法的基本原理和執(zhí)行過(guò)程并完成程序設(shè)計(jì)。實(shí)驗(yàn)內(nèi)容對(duì)給定數(shù)據(jù)集用fp增長(zhǎng)算法進(jìn)行挖掘,找出其屮的頻繁集并生成關(guān)聯(lián)規(guī)則。 對(duì)下面數(shù)據(jù)集進(jìn)行挖掘:實(shí)驗(yàn)步驟 首先數(shù)據(jù)庫(kù)第一次掃描,導(dǎo)出頻繁項(xiàng)集(1項(xiàng)集)的集合和支持度計(jì)數(shù)。頻繁 項(xiàng)的集合按支持度計(jì)數(shù)的遞減序排序,記為l,同時(shí)對(duì)事物數(shù)據(jù)庫(kù)的每條記錄也 進(jìn)行排序。 構(gòu)造fp樹(shù),建fp-trcc的根節(jié)點(diǎn),記為t,并且標(biāo)記為fuir。然后對(duì)數(shù)據(jù)庫(kù)d 中的毎個(gè)事務(wù)t,把t中排好序的事務(wù)項(xiàng)列表進(jìn)行建樹(shù),為方便樹(shù)的遍歷創(chuàng)建一個(gè) 項(xiàng)頭表。

2、 fp-樹(shù)挖掘處理:由長(zhǎng)度為1的頻繁模式(初始后綴模式)開(kāi)始,構(gòu)造它的條 件模式基。然后,構(gòu)造它的(條件)fp-樹(shù),并遞歸地在該樹(shù)上進(jìn)行挖掘。模式 增長(zhǎng)通過(guò)后綴模式與由條件fp-樹(shù)產(chǎn)生的頻繁模式連接實(shí)現(xiàn)。實(shí)驗(yàn)過(guò)程主要代碼:using system;using systcm.collcctions;using system. collections. generic;using system. componentmodel; using system. data;using system. drawing;using systcm.tcxt;using system. windows. form

3、s;using system 10;namespace fptree/ <summary>/ fptree獲取頻繁模式/ </summary>public partial class formfptree : form / <summary>/最小支持度計(jì)數(shù)/ </summary>static int minsupcount = 2;/ <summary>/最小支持度/ </summarystatic int minsuppercent = 22;/ <summary>/事務(wù)數(shù)據(jù)庫(kù)中的所有事務(wù)總數(shù)/ </sum

4、marystatic int totalltcms 二 0;/ <summary>/測(cè)試集的文件名/ </summary>static string _testset 二“;region測(cè)試數(shù)據(jù)集路徑 static string testdatai ,ztcstdatal_for_fp dat,z;static string testdata2 ,ztestdata2_for_fp. dat;static string testdata3 ,ztestdata3_for_fp. dat;#cndrcgion=application. startuppath +=appl

5、ication. startuppath +二 application.startuppath +public formfptree()initializecomponent();cbminsuppcrccnt. sclcctcdlndcx 二 0;/ <summary>/分析數(shù)據(jù)/ </suinmary>/ <param name=/z_datasetfi 1 eame/z></param> private void doanalysis(string datasetfilemame) "/fptreefptree fptree =

6、new fptree ();/fptree 挖掘fpgrowthfacade _fpgrowthfacade = new fpgrowthfacade();datetime _datetimestart = datetime. now; 讀取數(shù)福集,并遍歷取得頻繁一項(xiàng)集 readf i1e (datasetf i1ename, fptree);_fptrcc. initializcfptrcco ;_fpgrowthfacade. fpgrowth( fptree, null);_content. text 二“;if (_fpgrowthfacade. frequentpattern. co

7、unt > 0)"datetime _datetimeend 二 datetime. now;timespan _span 二(_datetimeend - _datetimestart); _content. text +="程序分析總時(shí)間:"+_span.totalseconds. tostring() +"支持度閥值設(shè)置:計(jì)數(shù) + minsupcount + ",支持度"+ math.round(float)minsupcount / totalltems, 3) * 100 + rnrn;foreach (diction

8、aryentry _cntry in _fpgrowthfacade. frequentpattern)" list<itemset> _tmpitemsetlist 二(li st<ttemset>)_fpgrowthfacade. frequentpattern_entry. key; _contcnt. text +="頻繁 + _cntry. key + "項(xiàng)集"+ _tmpitcmsctlist count+ 個(gè)rrt;foreach (itemset itemset in _tmpitemsetlist) "

9、 "string _contents 二 newstring_itcmsct. content. count;_itemset.content. copyto(_contents); _content. text +二 showinorder( fptree, _contents) + (計(jì)數(shù) + _itemset. count + 支持度” +math. round(float) itemset. count / totalltems, 3)*100 +)rn;_contcnt. text +="頻繁一項(xiàng)集"+_fptree. frequentltemcount

10、 + 個(gè):rn;foreach (dictionaryentry _entry fptree. hashfrequentltemtable)in_contcnt.text +二 _cntry. key _entry. value. tostring () +,支持度 +math. round(float)convert. tolnt32 ( entry. value) + %)rr;+ (計(jì)數(shù) +/ totalltems, 3) * 100fptree disposeall();_fpgrowthfacade. disposeall();/summary按順序顯示字符</suminary

11、><param name二_fptree>/param> <param name二_contents/z></param> <rcturns>/rcturns>private string showlnorder(fptree _fptree, string _contents)int _indexs 二 new int_contents. length; (int i 二 0; i < _indexs. length; i+)forindexsi = _fptree. getsupcountbyld(_contentsi

12、);int forcount 二 _indexs. length;(int bubble 二 0; bubble< count; bubble+)for (int lookup 二 bubble+ 1; lookup < count; lookup+)小的計(jì)數(shù)往下排 if (indexsbubble indexslookup)string temp = _contentsbubble; _contentsbubble = _contentslookup; _contentslookup二 temp;string tmpcontents 二 ;for (int i = 0; i &l

13、t; _contcnts. lcngth; i+)tmpcontents += contentsi +" “;" "return tmpcontents;region系統(tǒng)方法private void buttonl click (object sender, eventargs e) "if (totalltcnis = 0)messagebox. show(,z請(qǐng)先預(yù)處理數(shù)據(jù),以計(jì)算事務(wù)總數(shù)","系 統(tǒng)提示);return;setfilepatho ;setminsuppercent();if (_testset !二“)doana

14、lysis (_tcstsct); flowlayoutpanell.enabled = true; totalltems = 0;private void toolstripbutton2_click(object sender, eventargs e) close ();private void toolstripbutton3_click(objcct sender, eventargs e) setfilepatho ;/預(yù)處理,計(jì)算事務(wù)總項(xiàng)數(shù)flowlayoutpanell. enabled 二 false;streamreader sr 二 new streamreader(te

15、stset,system. text encoding. default);while (sr. peeko >= 0)讀取當(dāng)前行 sr. readlineo ;totalltems+;sr. closeo ;iii <summary>/設(shè)置數(shù)據(jù)所在位置/ </summary>private void setfilepath() if (smallset. checked)testset = testdatal;if (bigset. checked)testset 二 testdata2;if (standardsct checked) _testset = t

16、estdata3; "/ <summary>/設(shè)計(jì)支持度/ </summary>private void setminsuppercent() minsuppercent 二 convert. toint32(cbminsuppercent.sclcctcdltcm tostring() replace("%,");sendregionregion讀取數(shù)據(jù)集,并遍歷取得頻繁一項(xiàng)集public void readfile(string strfilename, fptree _fptrec) 設(shè)置支持度計(jì)數(shù)minsupcount 二 conv

17、ert.tolnt32(minsuppercent) * totalltems /100;strcamrcadcr sr 二 new strcamrcadcr(strf訂cnamc, system. text. encoding. default);string slinestring = “;str in g _arrt temneime = null;string _itcmname 二 null;/設(shè)置測(cè)試數(shù)據(jù)集開(kāi)始位置int _start 二 0;if (_testset 二二 testdatal)_start = 1;/用hashtable來(lái)保存一項(xiàng)集hashtable _hasht

18、able = new hashtoble();list<list<itcminfo>> liststrlist 二 newlist<list<ltemlnfo>>();+ 1;while (sr. peek() >二 0)讀取當(dāng)前行 slinestring = sr.readline();提取當(dāng)前行的數(shù)組_arrltemame 二 slinestring. split (new chart ' ' stringsplitoptions. removeemptyentries);/將數(shù)組放到內(nèi)存屮/_arrstrlist. add(_arr1temname);list<ltemlnfo> listltemname = new list<ltemlnfo>(); /將頻繁項(xiàng)集合放至ijhashtable中for (int i 二 start; i < arrltemname. length; i+)itemname = arritemnamei; _listitemname. add( new ttemt

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論