问题描述
我在看书 Jason Bell - 机器学习 - 开发人员和技术专业人员的实践。 EAN 9781119642251 出版社 John Wiley & Sons
先生贝尔在书中有一些例子,读者应该自己做。
我在第 5 章的示例中遇到问题 - 使用 Weka 创建决策树。 目标是使用 WEKA Toolkit 创建决策树。我使用版本 3.8.5。 提供训练集here。
我必须做的唯一步骤如下:
- 打开 Weka 程序
- 点击资源管理器按钮。
- 单击“打开文件”按钮并选择名为 Ladygaga.arff 的数据文件。
- 点击按钮顶行中的分类按钮。
- 在“分类器”窗格中,单击“选择”按钮并选择“树”菜单标题下的 J48 选项。
- 单击“开始”按钮并查看分类器输出窗口
这里我的问题开始了。我的输出与书中的完全不同。
预订:
J48 pruned tree
------------------
placement = end_rack: yes (5.0/1.0)
placement = cd_spec
| pricing <= 80: yes (2.0)
| pricing > 80: no (2.0)
placement = std_rack
| eye_level = TRUE: yes (2.0)
| eye_level = FALSE: no (3.0)
Number of Leaves : 5
Size of the tree : 8
我的输出:
J48 pruned tree
------------------
eye_level = TRUE: yes (6.0/2.0)
eye_level = FALSE: no (8.0/3.0)
Number of Leaves: 2
Size of the tree : 3
这是完全不同的。 :-D 我不明白为什么。
有人也做过那个例子吗? 我是否错过了书中的指导步骤? 还是书上没有写的必要设置?
解决方法
提供的数据文件是错误的,如果你按照这个改变数据,你会得到和书一样的结果。
@relation ladygaga
@attribute placement {end_rack,cd_spec,std_rack}
@attribute prominence numeric
@attribute pricing numeric
@attribute eye_level {TRUE,FALSE}
@attribute customer_purchase {yes,no}
@data
end_rack,85,FALSE,yes
end_rack,80,90,TRUE,yes
cd_spec,83,86,no
std_rack,70,96,68,65,64,72,95,69,yes
std_rack,75,no
end_rack,no
cd_spec,81,71,91,yes