


下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、.function D = C4_5(train_features, train_targets, inc_node, region)% Classify using Quinlan's C4.5 algorithm% Inputs:% features - Train features%targets- Train targets%inc_node- Percentage of incorrectlyassigned samples at a node%region- Decision region vector: -x x -yy number_of_points% Outputs
2、% D- Decision sufrace%NOTE: In this implementation it is assumed that a feature vector with fewer than 10 unique values (the parameter Nu)%is discrete, and will be treated as such. Other vectors will be treated as continuousNi, M= size(train_features);inc_node= inc_node*M/100;Nu= 10;%For the decisio
3、n regionN= region(5);mx= ones(N,1) * linspace(region(1),region(2),N);my= linspace (region(3),region(4),N)' *ones(1,N);flatxy= mx(:), my(:)'%Preprocessing%f, t, UW, m= PCA(train_features,train_targets, Ni, region);%train_features = UW * (train_features -m*ones(1,M);1 / 6.%flatxy= UW * (flatxy
4、 - m*ones(1,N2);%Findwhichoftheinputfeaturesarediscrete,anddiscretisize the corresponding%dimension on the decision regiondiscrete_dim = zeros(1,Ni);fori = 1:Ni,Nb = length(unique(train_features(i,:);if(Nb <= Nu),%This is a discrete featurediscrete_dim(i)= Nb;H, flatxy(i,:) =high_histogram(flatxy
5、(i,:), Nb);endend%Build the tree recursivelydisp('Building tree')tree= make_tree(train_features,train_targets, inc_node, discrete_dim,max(discrete_dim), 0);%Make the decision region according to the treedisp('Building decision surface using the tree')targets= use_tree(flatxy, 1:N2, t
6、ree,discrete_dim, unique(train_targets);D= reshape(targets,N,N);%ENDfunction targets = use_tree(features, indices, tree, discrete_dim, Uc)%Classify recursively using a treetargets = zeros(1, size(features,2);if(tree.dim = 0)%Reached the end of the tree2 / 6.targets(indices) = tree.child;breakend%Thi
7、s is not the last level of the tree, so: %First, find the dimension we are to work on dim = tree.dim;dims= 1:size(features,1);%And classify according to itif(discrete_dim(dim) = 0),%Continuous featurein= indices(find(features(dim,indices) <= tree.split_loc);targets= targets +use_tree(features(dim
8、s, :), in, tree.child(1),discrete_dim(dims), Uc);in= indices(find(features(dim,indices) > tree.split_loc);targets= targets +use_tree(features(dims, :), in, tree.child(2),discrete_dim(dims), Uc);else%Discrete featureUf= unique(features(dim,:);fori = 1:length(Uf),in= indices(find(features(dim,indic
9、es) = Uf(i);targets= targets +use_tree(features(dims, :), in, tree.child(i),discrete_dim(dims), Uc);endend%END use_treefunction tree = make_tree(features, targets, inc_node, discrete_dim, maxNbin, base)3 / 6.%Build a tree recursivelyNi, L= size(features);Uc= unique(targets);tree.dim= 0;%tree.child(1
10、:maxNbin) = zeros(1,maxNbin);tree.split_loc= inf;ifisempty(features),breakend%When to stop: If the dimension is one or the number of examples is smallif(inc_node> L)|(L= 1)|(length(Uc)= 1),H= hist(targets, length(Uc);m, largest= max(H);tree.child= Uc(largest);breakend%Compute the node's Ifori
11、 = 1:length(Uc),Pnode(i)= length(find(targets= Uc(i)/L;endInode = -sum(Pnode.*log(Pnode)/log(2);%For each dimension,computethegainratioimpurity%Thisisdone separatelyfordiscreteand continuousfeaturesdelta_Ib= zeros(1, Ni);split_loc= ones(1, Ni)*inf;fori = 1:Ni,data = features(i,:);Nbins= length(uniqu
12、e(data);if(discrete_dim(i),%This is a discrete feature4 / 6.P= zeros(length(Uc), Nbins);forj = 1:length(Uc),fork = 1:Nbins,indices= find(targets = Uc(j) &(features(i,:) = k);P(j,k) = length(indices);endendPk= sum(P);P= P/L;Pk= Pk/sum(Pk);info= sum(-P.*log(eps+P)/log(2);delta_Ib(i) =(Inode-sum(Pk
13、.*info)/-sum(Pk.*log(eps+Pk)/log(2);else%This is a continuous featureP = zeros(length(Uc), 2);%Sort the featuressorted_data, indices = sort(data);sorted_targets = targets(indices);%Calculate theinformationfor eachpossiblesplitI = zeros(1, L-1);forj = 1:L-1,fork =1:length(Uc),P(k,1)= length(find(sort
14、ed_targets(1:j)= Uc(k); P(k,2) =length(find(sorted_targets(j+1:end) = Uc(k); endPs= sum(P)/L;P= P/L;info= sum(-P.*log(eps+P)/log(2);I(j)= Inode - sum(info.*Ps);end5 / 6.delta_Ib(i), s = max(I);split_loc(i) = sorted_data(s);endend%Find the dimension minimizing delta_Ibm, dim = max(delta_Ib);dims= 1:N
15、i;tree.dim = dim;%Split along the 'dim' dimensionNf= unique(features(dim,:);Nbins= length(Nf);if(discrete_dim(dim),%Discrete featurefori = 1:Nbins,indices= find(features(dim, :) =Nf(i);tree.child(i) = make_tree(features(dims, indices), targets(indices), inc_node, discrete_dim(dims), maxNbin, base);endelse%Continuous featuretree.split_loc= split_loc(dim);indices1= find(features(dim,:) <=split_loc(dim);indices2= find(features(dim,
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年細(xì)胞治療產(chǎn)品臨床試驗(yàn)法規(guī)解讀與審批流程報(bào)告
- 海上風(fēng)能資源評(píng)估報(bào)告2025年深遠(yuǎn)海風(fēng)電發(fā)展規(guī)劃海上風(fēng)電場(chǎng)經(jīng)濟(jì)效益分析
- 茶與咖啡的跨界融合:2025年市場(chǎng)發(fā)展趨勢(shì)與品牌競(jìng)爭(zhēng)力研究報(bào)告
- 城市自來水廠升級(jí)改造2025年環(huán)境友好型技術(shù)應(yīng)用報(bào)告
- 2025年智能倉儲(chǔ)貨架制造項(xiàng)目智能控制系統(tǒng)研發(fā)報(bào)告
- 物聯(lián)網(wǎng)設(shè)備安全漏洞防護(hù)策略深度剖析:2025年技術(shù)標(biāo)準(zhǔn)解讀報(bào)告001
- 2025年醫(yī)院信息化建設(shè)電子病歷系統(tǒng)優(yōu)化策略研究報(bào)告
- 2025年醫(yī)院電子病歷系統(tǒng)優(yōu)化在醫(yī)院信息化建設(shè)中的數(shù)據(jù)安全防護(hù)機(jī)制研究報(bào)告
- 2025年城市地下綜合管廊建設(shè)專項(xiàng)債券資金申請(qǐng)財(cái)務(wù)分析報(bào)告
- 2025年醫(yī)藥行業(yè)CRO研發(fā)外包模式下的研發(fā)項(xiàng)目管理培訓(xùn)與咨詢報(bào)告
- 思維可視化工具在英語教學(xué)中的應(yīng)用探究 論文
- GMP清潔驗(yàn)證課件
- 養(yǎng)老護(hù)理員四級(jí)理論試題及答案
- 脊柱內(nèi)鏡技術(shù)
- 采購詢價(jià)單模板
- 心理測(cè)量課件-常見量表介紹與應(yīng)用
- 隆鼻術(shù)后護(hù)理查房
- 關(guān)于進(jìn)境食用水生動(dòng)物指定監(jiān)管場(chǎng)地名單
- 2023年主任醫(yī)師(正高)-中醫(yī)內(nèi)科學(xué)(正高)考試歷年真題集錦附答案
- 農(nóng)村分家協(xié)議書4篇
- 2023-2024學(xué)年江蘇省江都市小學(xué)語文三年級(jí)期末高分測(cè)試題詳細(xì)參考答案解析
評(píng)論
0/150
提交評(píng)論