1.下表由雇员数据库的训练数据组成,数据已泛化。例如,年龄“31…35”表示31到35的之间。对于给定的行,count表示department, status, age和salary在该行上具有给定值的元组数。 status是类标号属性。
department sales sales sales systems systems systems systems marketing marketing secretary secretary status senior junior junior junior senior junior senior senior junior senior junior age 31...35 26...30 31...35 21...25 31...35 26...30 41...45 36...40 31...35 46...50 26...30 salary 46K...50K 26K...30K 31K...35K 46K...50K 66K...70K 46K...50K 66K...70K 46K...50K 41K...45K 36K...40K 26K...30K count 30 40 40 20 5 3 3 10 4 4 6 1)如何修改基本决策树算法,以便考虑每个广义数据元组(即每个行)的count。
Status 分为2个部分: Department分为4个部分: Senior 共计52 Sales 共计110 Junior 共计113 Systems 共计 31 Marketing 共计14
Secretary 共计10
Age分为6个部分: Salary分为6各部分: 21…25 共计20 26K…30K 共计46
26…30 共计49 31K…35K 共计40 31…35 共计79 36K…40K 共计4 36…40 共计10 41K…45K 共计4 41…45 共计3 46K…50K 共计63 46…50 共计4 66K…70K 共计8
位
位
位
位
位
位
位
由以上的计算知按信息增益从大到小对属性排列依次为:salary、age、department,所以定salary作为第一层,之后剩下的数据如下: department sales systems systems marketing status senior junior junior senior age 31...35 21...25 26...30 36...40 salary 46K...50K 46K...50K 46K...50K 46K...50K count 30 20 3 10
由这个表可知department和age的信息增益将都为0。所以第二层可以为age也可以为department。
2)构造给定数据的决策树。
由上一小问的计算所构造的决策树如下: Salary 26K:30K 66K:70K 31K:35K Junior Senior 36K:40K 41K:45K 46K:50K Junior Senior Junior Age 21:25 26:30 36:40 31:35 Junior Junior Senior 3)给定一个数据元组,它在属性department,?age和salary上的值分别为“systems”,“26...30?”Senior 和“46...50K”。该元组status的朴素贝叶斯分类结果是什么? P(status=senior)=52/165=0.3152 P(status=junior)=113/65=0.6848
P(department=systems|status=senior)=8/52=0.1538 P(department=systems|status=junior)=23/113=0.2035 P(age=26…30|status=senior)=1/52=0.0192 P(age=26…30|status=junior)=49/113=0.4336 P(salary=46K…50K|status=senior)=40/52=0.7692 P(salary=46K…50K|status=junior)=23/113=0.2035 使用上面的概率,得到:
P(X|status=senior)=P(department=systems|status=senior)*P(age=26…30|status=senior)* P(salary=46K…50K|status=senior)=0.0023
P(X|status=junior)=P(department=systems|status=junior)*P(age=26…30|status=junior)* P(salary=46K…50K|status= junior)=0.0180 P(X|status=senior)* P(status=senior)= 7.2496e-004 P(X|status=junior)* P(status=junior)=0.0123
因此,对于元组X,朴素贝叶斯分类预测元组X的类为status=junior
2. 运用决策树或者贝叶斯算法,对鸢尾花数据集进行分类,显示分类结果。 (可以采用Weka工具或者其他方法)
在weka上运用决策树算法对鸢尾花数据集进行分类,分类结果如下图所示: 在weka上运用贝叶斯算法对鸢尾花数据进行分类,结果的具体情况如下:
数据挖掘作业



