




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、數(shù)據(jù)挖掘算法實(shí)驗(yàn)報(bào)告1) 實(shí)驗(yàn)題目基于決策樹(shù)的分類(lèi)算法,屬性的選擇采用ID3或C4.5策略,采用如下的數(shù) 據(jù)建立分類(lèi)決策樹(shù)。ageincomestudentcredit ratingbuys computer=30highnofairno40mediumnofairves40lowyesrairyes4Qlowvesexcellentno31. .40lowvesexcellentves=30mediumnofairno40mediumyesfairyes40mediumnoexcelentno2)算法基本思想的描述ID3選擇具有最高信息熵增益的屬性作為分裂屬性,基于這種原則我們 首先可以算出
2、初始集合的熵,然后分別求出以各個(gè)屬性為分裂屬性時(shí)的熵, 然后將通過(guò)上面得到的數(shù)據(jù)算出以各個(gè)屬性為分裂屬性時(shí)的信心增益,選擇 具有最大的信息增益屬性作為我們的分裂屬性。3) 編程實(shí)現(xiàn)算法#include #include #include using namespace std;#define SIZE 14struct Data(char age10;char income10;char student10;char credit_rating20;char buys_computer10;;Data data SIZE=(=30,high,氣o,fair,氣o,40,medium,no,fa
3、ir,yes,40,low,yes,fair,yes,40,low,yes,excellent,no,31.40,low,yes,excellent,yes,=30,medium,no,fair,no,40,medium,yes,fair,yes,40,medium,no,excellent,no;double calculate(double a,double b);void origin_entropy(Data data,double &entropy);void age_entropy(Data data,double &entropy);void income_entropy(Dat
4、a data,double &entropy);void student_entropy(Data data,double &entropy);void credit_rating_entropy(Data data,double &entropy);int main()(double origin=0,age=0,student=0,credit_rating=0,income=0;origin_entropy(data,origin);age_entropy(data,age);student_entropy(data,student);income_entropy(data,income
5、);credit_rating_entropy(data,credit_rating);coutinfo(D)=originendl;cout用 age 作為分裂屬性時(shí):偵熵 info(age)(D)=agett信息增益為:origin-ageendl;cout用 income 作為分裂屬性時(shí):n熵 info(income)(D)=incomett 信 息 增 益 為:origin-incomeendl;cout用 student 作為分裂屬性時(shí):n熵 info(student)(D)=):studenttt 信 息 增 益 為:origin-studentendl;cout用 credit_
6、rating 作為分裂屬性時(shí):n 熵 info(credit_rating)(D)=credit_ratingt 信息增益 為:origin-credit_ratingendl;return 0;double calculate(double a,double b)(if(a=0)return 0;elsereturn (a/b)*log10(b/a)/log10(2);void origin_entropy(Data data,double &entropy)(int i;double yes=0, no=0;for( i=0;iSIZE;i+)(if(strcmp(datai.buys_c
7、omputer,yes)=0)yes+;elseno+;entropy二calculate(yes,SIZE)+calculate(no,SIZE);void age_entropy(Data data,double &entropy)(double youth3=0;double middle3=0;double old3 = 0;for (int i=0;iSIZE;i+)(if(strcmp(datai.age,=30)=0)(strcmp(datai.buys_computer,yes)=0)?youth0+:youth1+ ;youth2+;else if(strcmp(datai.
8、age,31.40)=0)(strcmp(datai.buys_computer,yes)=0)?middle0+:middle1 +;middle2+;else(strcmp(datai.buys_computer,yes)=0)?old0+:old1+;old 2+;entropy二youth2/SIZE*(calculate(youth0,youth2)+calculate( youth1,youth2)+middle2/SIZE*(calculate(middle0,middle2 )+calculate(middle1,middle2)+old2/SIZE*(calculate(ol
9、d0 ,old2)+calculate(old1,old2);void income_entropy(Data data,double &entropy)(double high3 = 0;double medium3=0;double low3 = 0;for (int i=0;iSIZE;i+)(if(strcmp(datai.income,high)=0)(strcmp(datai.buys_computer,yes)=0)?high0+:high1+;h igh2+;else if(strcmp(datai.income,medium)=0)(strcmp(datai.buys_com
10、puter,yes)=0)?medium0+:medium1 +;medium2+;else(strcmp(datai.buys_computer,yes)=0)?low0+:low1+;low 2+;entropy=high2/SIZE*(calculate(high0,high2)+calculate(hig h1,high2)+medium2/SIZE*(calculate(medium0,medium2)+ca lculate(medium1,medium2)+low2/SIZE*(calculate(low0,low 2)+calculate(low1,low2);void stud
11、ent_entropy(Data data,double &entropy)(double yes3 = 0;double no3 = 0;for (int i=0;iSIZE;i+)(if(strcmp(datai.student,yes)(strcmp(datai.buys_computer,yes)?yes0+:yes1+;yes2+7else(strcmp(datai.buys_computer,yes)?no0+:no1+;no2+;entropy=yes2/SIZE*(calculate(yes0,yes2)+calculate(yes1,yes2)+no2/SIZE*(calculate(no0,no2)+calculate(no1,no 2);void credit_rating_entropy(Data data,double &entropy)(double fair3 = 0;double excellent3=0;for (int i=0;iSIZE;i+)(if(strcmp(datai.credit_rating,fair)(strcmp(datai.buys_computer,yes)?fair0+:fair1+;fair2+;else(strcmp(datai.buys_computer,yes)?excellent0+:exce
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 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ì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 創(chuàng)新科技在醫(yī)療信息安全領(lǐng)域的突破
- 電氣工程師資格考試夢(mèng)幻組合試題及答案
- 2024年紡織機(jī)械知識(shí)傳授試題及答案
- 以患者為中心的智慧醫(yī)療模式構(gòu)建-基于區(qū)塊鏈的應(yīng)用研究
- 分析績(jī)效表現(xiàn)2024年酒店經(jīng)營(yíng)管理師考試試題與答案
- 健康教育與提升公眾健康意識(shí)對(duì)改善醫(yī)患關(guān)系的影響研究
- 中醫(yī)健康理念引領(lǐng)的生態(tài)服裝設(shè)計(jì)研究
- 2024質(zhì)量工程師考試分?jǐn)?shù)提升方法分享試題及答案
- 機(jī)械工程師職業(yè)道德試題及答案
- 2024年Adobe設(shè)計(jì)師考試復(fù)習(xí)方法試題及答案
- (完整版)外科護(hù)理學(xué)知識(shí)點(diǎn)整理
- 2019版《壓力性損傷的預(yù)防和治療:臨床實(shí)踐指南》解讀
- 在那遙遠(yuǎn)的地方課件
- 圍堰吹填施工方案
- 創(chuàng)業(yè)計(jì)劃書(shū)案例-產(chǎn)品類(lèi)-南大無(wú)醇酒創(chuàng)業(yè)完全版
- 食品生產(chǎn)企業(yè)動(dòng)態(tài)風(fēng)險(xiǎn)因素量化分值表食品生產(chǎn)日常監(jiān)督檢查要點(diǎn)表
- 基層醫(yī)療衛(wèi)生機(jī)構(gòu)依法執(zhí)業(yè)自查表
- 氣管插管術(shù)培訓(xùn)課件
- 普通高等學(xué)校畢業(yè)生就業(yè)協(xié)議書(shū)(三方協(xié)議)
- 電腦故障診斷卡說(shuō)明書(shū)
- 2022年7月2日江蘇省事業(yè)單位招聘考試《綜合知識(shí)和能力素質(zhì)》(管理崗客觀題)及答案
評(píng)論
0/150
提交評(píng)論