資源簡(jiǎn)介
壓縮包中包含決策樹(shù)分類(lèi)方法,還有隨機(jī)森林方法的matlab代碼。

代碼片段和文件信息
clear?all;??
rnode=cell(31);%3*1的單元數(shù)組??
%?rchild_value=cell(31);%3*1的單元數(shù)組??
%?rchild_node_num=cell(31);%3*1的單元數(shù)組??
sn=300;?%隨機(jī)可重復(fù)的抽取sn個(gè)樣本??
tn=10;??%森林中決策樹(shù)的數(shù)目
load(‘a(chǎn)aa.mat‘);??
n?=?size(r1);
%%?樣本訓(xùn)練采用隨機(jī)森林和ID3算法構(gòu)建決策森林??
discrete_dim?=?[];
for?j=1:tn??
????Sample_num=randi([1n]1sn);%從1至1000內(nèi)隨機(jī)抽取sn個(gè)樣本??
????SData=r(Sample_num:);??
????[treediscrete_dim]=?train_C4_5(SData?5?10?discrete_dim);??
????rnode{j1}=tree;??
end??
??????
%%?樣本測(cè)試??
load(‘a(chǎn)aa.mat‘);??
T?=?r;
%TData=roundn(T-1);??
TData?=?roundn(T-1);??
%統(tǒng)計(jì)函數(shù),對(duì)輸入的測(cè)試向量進(jìn)行投票,然后統(tǒng)計(jì)出選票最高的標(biāo)簽類(lèi)型輸出??
result?=?statistics(tn?rnode?TData?discrete_dim)?
gd?=?T(:end);
len?=?length(gd);
count?=?sum(result==gd);
fprintf(‘共有%d個(gè)樣本,判斷正確的有%d\n‘lencount);
????
????
?
??????
??????
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件?????160768??2013-02-07?14:41??RandomForest\aaa.xls
?????文件?????146432??2013-02-07?14:41??RandomForest\bbb.xls
?????文件???????4570??2013-02-10?21:39??RandomForest\ID3.m
?????文件????????974??2017-12-26?17:49??RandomForest\RandomForest.m
?????文件?????176128??2018-01-09?22:51??RandomForest\result.xls
?????文件???????2256??2013-02-10?22:02??RandomForest\statistics.m
?????文件????????938??2013-02-10?21:55??RandomForest\suijisenlin.asv
?????文件????4218541??2017-09-05?15:59??random?forest-matlab\aaa.mat
?????文件????????888??2018-01-18?22:25??random?forest-matlab\rfmain.m
?????文件????????673??2017-09-06?10:19??random?forest-matlab\statistics.m
?????文件??????13496??2017-12-20?19:50??random?forest-matlab\train_C4_5.m
?????文件???????1947??2017-09-06?09:24??random?forest-matlab\vote_C4_5.m
?????目錄??????????0??2018-01-09?22:51??RandomForest
?????目錄??????????0??2017-09-06?10:58??random?forest-matlab
-----------?---------??----------?-----??----
??????????????4727611????????????????????14
評(píng)論
共有 條評(píng)論