没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论















function D = C4_5(train_features, train_targets, inc_node, region)
% Classify using Quinlan's C4.5 algorithm
% Inputs:
% features - Train features
% targets - Train targets
% inc_node - Percentage of incorrectly assigned samples at a node
% region - Decision region vector: [-x x -y y number_of_points]
%
% Outputs
% D - Decision sufrace
%NOTE: In this implementation it is assumed that a feature vector with fewer than 10 unique values (the parameter Nu)
%is discrete, and will be treated as such. Other vectors will be treated as continuous
[Ni, M] = size(train_features);
inc_node = inc_node*M/100;
Nu = 10;
%For the decision region
N = region(5);
mx = ones(N,1) * linspace (region(1),region(2),N);
my = linspace (region(3),region(4),N)' * ones(1,N);
flatxy = [mx(:), my(:)]';
%Preprocessing
%[f, t, UW, m] = PCA(train_features, train_targets, Ni, region);
%train_features = UW * (train_features - m*ones(1,M));;
%flatxy = UW * (flatxy - m*ones(1,N^2));;
% Classify using Quinlan's C4.5 algorithm
% Inputs:
% features - Train features
% targets - Train targets
% inc_node - Percentage of incorrectly assigned samples at a node
% region - Decision region vector: [-x x -y y number_of_points]
%
% Outputs
% D - Decision sufrace
%NOTE: In this implementation it is assumed that a feature vector with fewer than 10 unique values (the parameter Nu)
%is discrete, and will be treated as such. Other vectors will be treated as continuous
[Ni, M] = size(train_features);
inc_node = inc_node*M/100;
Nu = 10;
%For the decision region
N = region(5);
mx = ones(N,1) * linspace (region(1),region(2),N);
my = linspace (region(3),region(4),N)' * ones(1,N);
flatxy = [mx(:), my(:)]';
%Preprocessing
%[f, t, UW, m] = PCA(train_features, train_targets, Ni, region);
%train_features = UW * (train_features - m*ones(1,M));;
%flatxy = UW * (flatxy - m*ones(1,N^2));;
%Find which of the input features are discrete, and discretisize the corresponding
%dimension on the decision region
discrete_dim = zeros(1,Ni);
for i = 1:Ni,
Nb = length(unique(train_features(i,:)));
if (Nb <= Nu),
%This is a discrete feature
discrete_dim(i) = Nb;
[H, flatxy(i,:)] = high_histogram(flatxy(i,:), Nb);
end
end
%Build the tree recursively
disp('Building tree')
tree = make_tree(train_features, train_targets, inc_node, discrete_dim, max(discrete_dim), 0);
%Make the decision region according to the tree
disp('Building decision surface using the tree')
targets = use_tree(flatxy, 1:N^2, tree, discrete_dim, unique(train_targets));
D = reshape(targets,N,N);
%END
function targets = use_tree(features, indices, tree, discrete_dim, Uc)
%Classify recursively using a tree
targets = zeros(1, size(features,2));
if (tree.dim == 0)
%Reached the end of the tree
%dimension on the decision region
discrete_dim = zeros(1,Ni);
for i = 1:Ni,
Nb = length(unique(train_features(i,:)));
if (Nb <= Nu),
%This is a discrete feature
discrete_dim(i) = Nb;
[H, flatxy(i,:)] = high_histogram(flatxy(i,:), Nb);
end
end
%Build the tree recursively
disp('Building tree')
tree = make_tree(train_features, train_targets, inc_node, discrete_dim, max(discrete_dim), 0);
%Make the decision region according to the tree
disp('Building decision surface using the tree')
targets = use_tree(flatxy, 1:N^2, tree, discrete_dim, unique(train_targets));
D = reshape(targets,N,N);
%END
function targets = use_tree(features, indices, tree, discrete_dim, Uc)
%Classify recursively using a tree
targets = zeros(1, size(features,2));
if (tree.dim == 0)
%Reached the end of the tree
剩余6页未读,继续阅读

War03
- 粉丝: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 图像处理(第3章).ppt
- 通用统计报表数据处理软件SARP2000V30开发与使用.docx
- 基础教育信息化环境建设问题及发展建议.pdf
- 基于PLC全自动洗衣机毕业设计1.doc
- 用友软件对鼎捷软件神州数码的竞争策略分析.pptx
- 网络安全培训教材(PPT 51页).pptx
- 基于冲突再分配DSmT的多尺度融合边缘检测算法[最终版].pdf
- (源码)基于Python的模因生命引导程序.zip
- 事故隐患治理项目管理规定.docx
- 项目管理人员试题(含答案).doc
- 完美版资料新嵌入式课程设计龙傲天小组.docx
- 微软招聘过程及经验(3).pptx
- 计算机应用基础2-4.ppt
- 基于单片机的酒精浓度测试系统设计.doc
- 蓝莓网络营销策划方案策划书.doc
- 校园网络安全知识竞赛试题.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制

- 1
- 2
前往页