⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 detreeexp1_4.asv

📁 支持向量机工具箱
💻 ASV
字号:

%设置全局变量
global meas species bad numobs
global  x y j tree


%Treefit函数能为数据集找到适合的决策树。
%我们为这个Iris花数据集创建一棵决策树
%并且观察它在分类Iris花的种群时候的好处和优势。

tree = treefit(meas(:,1:2), species);

% treeval计算决策树的代价
[dtnum,dtnode,dtclass] = treeval(tree, meas(:,1:2));

%计算决策树分类误差
bad_d = ~strcmp(dtclass,species);
sum(bad_d) / numobs

%创建含有x轴,y轴的栅格图来显示决策树分类区域
[grpnum,node,grpname] = treeval(tree, [x y]);
gscatter(x,y,grpname,'grb','sop')
xlabel('萼片长度');
ylabel('萼片宽度');
hold on;
plot(meas(bad_d,1), meas(bad_d,2), 'kx');
hold off;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -