决策树学习算法
我想先说这是一项家庭作业。
我得到一组 Q 二进制输入变量,用于对 Y 的输出进行分类,Y 也是二进制的。
问题的第一部分是:我最多需要多少个例子来枚举Q的所有可能组合?我目前认为,由于它最多要求我需要 Q ,因为 Q-1 之前的所有值可能都是相同的,例如 1 ,而 Q 处的项目是 0 。
问题的第二部分是:树最多可以有多少个叶子节点给出Z个例子?
我目前的答案是,树最多有 2 个叶节点,一个代表 true,一个代表 false,因为它处理的是二进制输入和二进制输出。
这是检查这个问题的正确方法还是我太深入地概括了我的答案?
编辑
在查看卡梅伦的回复后,我现在将我的第一个答案变成 2^Q 并以他的 Q = 3 的示例为基础,我将得到 2^3 或 8 (2*2*2)。如果有不正确的想法请指正。
编辑 #2
问题的第二部分看起来应该是 (2^Q) * Z 或提供一个示例:(2^3) * 3) 或 8*3 = 24 个叶节点。回顾一下,如果我有 3 个二进制输入,我最初会取 2^3,现在得到 8 个,现在我想看 3 个例子。因此我应该得到 8*3 或 24。
编辑#3
事后看来,无论我使用多少个例子,叶节点的数量都不应该增加,因为它是基于每棵树的。
I want to preface this by saying that this is a homework assignment.
I am given a set of Q binary input variables that will be used to classify output of Y which is also binary.
The first part of the question is: at most how many examples do I need to enumarate all possibile combinations of Q? I am currently think that since it asks for at most I will need Q as it is possible that all values up to Q-1 are the same for instance 1 and the item at Q is 0 .
The second part of the question is: at most how many leaf nodes can the tree have given Z examples?
My current answer is that at most the tree would have 2 leaf nodes, one representing true and one representing false since it is dealing with binary inputs and binary outputs.
Is this the correct way of examining this problem or am I generalizing my answers too deeply?
Edit
After looking at Cameron's response, I would now turn my first answer into 2^Q and to build on his example of Q = 3, I would get 2^3 or 8 (2*2*2). Please correct if that is incorrect thinking.
Edit #2
The second part of the question it appears as though it should be (2^Q) * Z or to provide an example: (2^3) * 3) or 8*3 = 24 leaf nodes. To recap if I have 3 inputs that are binary I would initially take 2^3 and get 8 now I want to go over 3 examples. Therefore I should get 8*3 or 24.
Edit #3
In hindsight it seems that no matter how many examples I use the number of leaf nodes should never increase, as it is a per tree basis.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您通过手动计算小示例来解决该问题。
对于第一部分,为
Q
选择一个较小的值,例如 3,并写下Q
的所有可能组合。然后你就可以算出你需要多少个例子。增加Q
并再做一次。对于问题的第二部分,选择一个小的
Z
并手动运行决策树算法。看看你得到了多少片叶子。然后选择另一个Z
并查看它是否/如何变化。尝试生成不同的示例(使用相同的Z
),看看是否可以更改叶子的数量。I'd suggest you approach the problem by working out small example cases by hand.
For the first part, choose a small value for
Q
, say 3, and write down all possible combinations ofQ
. Then you can figure out how many examples you need. IncreaseQ
and do it again.For the second part of your question, pick a small
Z
and run the decision tree algorithm by hand. See how many leaves you get. Then pick anotherZ
and see if/how it changes. Try generating different examples (with the sameZ
) and see if you can change the number of leaves.