資源簡(jiǎn)介
利用matlab 決策樹算法對(duì)某疾病進(jìn)行診斷的代碼示例,歡迎下載參考
代碼片段和文件信息
%%?決策樹分類器在乳腺癌診斷中的應(yīng)用研究(2009a版本)
%%?清空環(huán)境變量
clear?all
clc
warning?off
%%?導(dǎo)入數(shù)據(jù)
load?data.mat
%?隨機(jī)產(chǎn)生訓(xùn)練集/測(cè)試集
a?=?randperm(569);
Train?=?data(a(1:500):);
Test?=?data(a(501:end):);
%?訓(xùn)練數(shù)據(jù)
P_train?=?Train(:3:end);
T_train?=?Train(:2);
%?測(cè)試數(shù)據(jù)
P_test?=?Test(:3:end);
T_test?=?Test(:2);
%%?創(chuàng)建決策樹分類器
ctree?=?classregtree(P_trainT_train);
%?查看決策樹視圖
view(ctree);
%%?仿真測(cè)試
T_sim?=?eval(ctreeP_test);
%%?結(jié)果分析
count_B?=?length(find(T_train?==?1));
count_M?=?length(find(T_train?==?2));
rate_B?=?count_B?/?500;
rate_M?=?count_M?/?500;
total_B?=?length(find(data(:2)?==?1));
total_M?=?length(find(data(:2)?==?2));
number_B?=?length(find(T_test?==?1));
number_M?=?length(find(T_test?==?2));
number_B_sim?=?length(find(T_sim?==?1?&?T_test?==?1));
number_M_sim?=?length(find(T_sim?==?2?&?T_test?==?2));
disp([‘病例總數(shù):‘?num2str(569)...
??????‘??良性:‘?num2str(total_B)...
??????‘??惡性:‘?num2str(total_M)]);
disp([‘訓(xùn)練集病例總數(shù):‘?num2str(500)...
??????‘??良性:‘?num2str(count_B)..
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????1595??2013-09-02?16:03??main_2009a.m
?????文件???????2684??2013-09-02?16:04??main_2012b.m
?????文件????????356??2013-09-02?15:57??Readme.txt
?????文件??????86267??2009-11-29?15:48??data.mat
-----------?---------??----------?-----??----
????????????????90902????????????????????4
- 上一篇:置亂變換matlab代碼
- 下一篇:matlab求解乘法逆元
評(píng)論
共有 條評(píng)論