資源簡介
利用matlab 決策樹算法對某疾病進行診斷的代碼示例,歡迎下載參考
代碼片段和文件信息
%%?決策樹分類器在乳腺癌診斷中的應用研究(2009a版本)
%%?清空環境變量
clear?all
clc
warning?off
%%?導入數據
load?data.mat
%?隨機產生訓練集/測試集
a?=?randperm(569);
Train?=?data(a(1:500):);
Test?=?data(a(501:end):);
%?訓練數據
P_train?=?Train(:3:end);
T_train?=?Train(:2);
%?測試數據
P_test?=?Test(:3:end);
T_test?=?Test(:2);
%%?創建決策樹分類器
ctree?=?classregtree(P_trainT_train);
%?查看決策樹視圖
view(ctree);
%%?仿真測試
T_sim?=?eval(ctreeP_test);
%%?結果分析
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([‘病例總數:‘?num2str(569)...
??????‘??良性:‘?num2str(total_B)...
??????‘??惡性:‘?num2str(total_M)]);
disp([‘訓練集病例總數:‘?num2str(500)...
??????‘??良性:‘?num2str(count_B)..
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????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求解乘法逆元
評論
共有 條評論