资源简介
使用matlab实现id3决策树算法,给出使用方法及举例,并附带相关测试集合。

代码片段和文件信息
%author: svmsunny
%mailto: chingsun00@gmail.com
classdef ID3Tree
properties
translator; %for translating the data type from string to number if necessary;
statistic_info; %for each dimension gather statistics
root;
train_set_dim;
end
methods
%function ========================================================
function obj = construct_tree(obj training_set data_type)
%training_set
%data_type: 1 for string and 0 for number. donnot consider
%the condition that some column are number and others are
%string.
%生成一个分类树
if data_type %translate the string data to number
translator = trans_data();
[trans_train obj.translator] = translator.translate_train(training_set);
clear training_set;
training_set = trans_train;
end
obj.train_set_dim = size(training_set2);
for i = 1 : size(training_set2) %column
clear table;
table = tabulate(training_set(:i));
cout = 1;
for j = 1 : size(table1) %
if table(j2) %not zero
statistic_info{1i}(1cout) = table(j1);
cout = cout + 1;
end
end
end
obj.statistic_info = statistic_info;
dim_visible = ones(1 size(training_set2)-1);
obj.root = make_tree(training_setdim_visiblestatistic_info);
end
%function ========================================================
function [cor_rationtargets] = classify(obj testing_set)
%
if ~isempty(obj.translator) % need to translate the data
trans_test = obj.translator.translate_test(testing_set);
clear testing_set;
testing_set = trans_test;
end
train_set_dimension = obj.train_set_dim; %include the class label column
classifier_tree = obj.root;
targets = zeros(size(testing_set1) 1);
for i = 1: size(testing_set 1)
targets(i 1) = classify_class(classifier_tree testing_set(i1:train_set_dimension-1));
end
if train_set_dimension == size(testing_set 2) %same dimension then get the correct ratio
cout = 0;
for i = 1: size(testing_set 1)
if testing_set(i end) == targets(i 1)
cout = cout + 1;
end
end
cor_ration = cout / size(testing_set 1);
else
cor_ration = -1; %not for testing the classifying Precision
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7972 2010-04-28 21:23 id3决策树\ID3Tree.m
文件 16416 2010-04-21 11:24 id3决策树\orig_abalone_test.txt
文件 62947 2010-04-21 11:25 id3决策树\orig_abalone_train.txt
文件 3317 2010-04-28 10:28 id3决策树\trans_data.m
文件 530 2010-04-28 21:19 id3决策树\usecase.m
目录 0 2010-04-28 21:20 id3决策树
----------- --------- ---------- ----- ----
91182 6
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论