Matlab:决策树显示无效的输出值
我正在使用 classregtree(X,Y) 函数制作决策树。我将 X 作为大小为 70X9 的矩阵(70 个数据对象,每个数据对象有 9 个属性)传递,将 Y 作为 70X1 矩阵传递。我的每个 Y 值不是 2 就是 4。但是,在形成的决策树中,它为某些叶节点提供了 2.5 或 3.5 的值。
有什么想法可能会造成这种情况吗?
I'm making a decision tree using the classregtree(X,Y) function. I'm passing X as a matrix of size 70X9 (70 data objects, each having 9 attributes), and Y as a 70X1 matrix. Each one of my Y values is either 2 or 4. However, in the decision tree formed, it gives values of 2.5 or 3.5 for some of the leaf nodes.
Any ideas why this might be caused?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在回归模式(这是默认模式)下使用 classregtree。
将模式更改为分类模式。
You are using classregtree in regression mode (which is the default mode).
Change the mode to classification mode.
以下是使用 CLASSREGTREE 进行分类的示例:
输出(混淆矩阵和准确性):
现在,如果您的目标类被编码为数字,则返回的预测仍将是字符串元胞数组,所以你必须将它们转换回数字:
请注意,分类将始终返回字符串,因此我认为您可能错误地使用了
method=regression
选项,该选项执行 回归(数字目标)不是 分类(离散目标)Here is an example using CLASSREGTREE for classification:
The output (confusion matrix and accuracy):
Now if your target class is encoded as numbers, the returned prediction will still be cell array of strings, so you have to convert them back to numbers:
Note that classification will always return strings, so I think you might have mistakenly used the
method=regression
option, which performs regression (numeric target) not classification (discrete target)