实验三-决策树算法实验实验报告.doc
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
实验三 决策树算法实验 一、实验目的: 熟悉和掌握决策树的分类原理、实质和过程;掌握典型的学习算法 和实现技术。 二、实验原理: 决策树学习和分类. 三、实验条件: 四、实验内容: 1 根据现实生活中的原型自己创建一个简单的决策树。 2 要求用这个决策树能解决实际分类决策问题。 五、实验步骤: 1、验证性实验: (1)算法伪代码 算法Decision_Tree(data,AttributeName) 输入由离散值属性描述的训练样本集data; 候选属性集合AttributeName。 输出一棵决策树。 (1) 创建节点N; (2) If samples 都在同一类C中then (3) 返回N作为叶节点,以类C标记; (4) If attribute_list为空then (5) 返回N作为叶节点,以samples 中最普遍的类标记;//多数表决 (6) 选择attribute_list 中具有最高信息增益的属性test_attribute; (7) 以test_attribute 标记节点N; (8) For each test_attribute 的已知值v //划分 samples ; (9) 由节点N分出一个对应test_attribute=v的分支; (10令Sv为 samples中 test_attribute=v 的样本集合;//一个划分块 (11)If Sv为空 then (12)加上一个叶节点,以samples中最普遍的类标记; (13)Else 加入一个由Decision_Tree(Sv,attribute_list- test_attribute)返回节点值。 (2)实验数据预处理 Age:30岁以下标记为"1";30岁以上50岁以下标记为"2";50岁以上标记为"3"。 Sex:F EMAL----"1";MALE----"2" Region:INNER CITY----"1";TOWN----"2"; RURAL----"3"; SUBURBAN---- "4" Income:5000~2万----"1";2万~4万----"2";4万以上---- "3" Married Children Car Mortgage Pep:以上五个条件,若为"是"标记为"1",若为"否"标记为"2"。 Age sex region income married children car mortgage pep 1 2 1 1 2 1 1 2 2 1 2 1 1 2 2 2 2 1 2 1 4 1 2 1 2 2 1 2 1 1 1 1 2 2 2 2 1 2 1 1 1 2 2 2 2 1 2 1 1 2 1 2 1 1 2 1 2 1 1 2 1 1 2 2 1 1 1 2 1 1 2 1 2 1 3 1 2 2 1 2 1 2 1 2 2 2 1 2 2 2 2 2 1 2 2 2 2 1 1 2 1 2 2 1 1 2 1 1 2 2 1 2 1 2 2 1 2 1 1 1 2 1 2 2 2 1 3 2 1 2 1 1 1 2 2 1 1 1 2 1 1 1 2 1 1 1 3 2 2 2 1 2 1 3 1 2 2 1 2 2 2 1 3 2 3 3 1 1 1 2 1 3 2 2 3 1 2 1 1 2 3 1 3 3 1 1 2 2 1 3 2 1 3 1 2 1 2 2 3 2 1 3 1 1 1 1 1 3 1 1 3 1 2 1 1 2 3 1 3 3 1 2 2 2 2 3 2 4 3 1 2 2 1 1 3 1 3 3 2 2 1 1 2 (3)Matlab语句: [Tree RulesMatrix]= DecisionTree(DataSet, AttributName); 六、实验结果: 实验程序: function [Tree RulesMatrix]=DecisionTree(DataSet,AttributName) %输入为训练集,为离散后的数字,如记录1:1 1 3 2 1; %前面为属性列,最后一列为类标 if nargin<1 error('请输入数据集'); else if isstr(DataSet) [DataSet AttributValue]=readdata2(DataSet); else AttributValue=[]; end end if nargin<2 AttributName=[]; end Attributs=[1:size(DataSet,2)-1]; Tree=CreatTree(DataSet,Attributs); disp([char(13) 'The Decision Tree:']); showTree(Tree,0,0,1,Attr
剩余12页未读,继续阅读
- 粉丝: 167
- 资源: 3万+
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx