Categorical Variables in Decision Tree
$begingroup$
I was going through the Andrew Ng's notes for Decision Trees. It has one section explaining the usage of categorical variables using Decision Trees in which I am not able to understand this part
" A caveat to the above is that we must take care to not allow a variable
to have too many categories. For a set of categories S, our set of possible
questions is the power set P(S), of cardinality 2^|S| . Thus, a large number of categories makes question selection computationally intractable. "
Q1 -> How is the possible set of questions is 2^|S| ? It should be equal to the non-leaf nodes in the decision tree .
Link to Andrew Ng notes on Decision Tree : http://cs229.stanford.edu/notes/cs229-notes-dt.pdf
Can you please give some clarification on it .
machine-learning decision-trees
New contributor
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
I was going through the Andrew Ng's notes for Decision Trees. It has one section explaining the usage of categorical variables using Decision Trees in which I am not able to understand this part
" A caveat to the above is that we must take care to not allow a variable
to have too many categories. For a set of categories S, our set of possible
questions is the power set P(S), of cardinality 2^|S| . Thus, a large number of categories makes question selection computationally intractable. "
Q1 -> How is the possible set of questions is 2^|S| ? It should be equal to the non-leaf nodes in the decision tree .
Link to Andrew Ng notes on Decision Tree : http://cs229.stanford.edu/notes/cs229-notes-dt.pdf
Can you please give some clarification on it .
machine-learning decision-trees
New contributor
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
I was going through the Andrew Ng's notes for Decision Trees. It has one section explaining the usage of categorical variables using Decision Trees in which I am not able to understand this part
" A caveat to the above is that we must take care to not allow a variable
to have too many categories. For a set of categories S, our set of possible
questions is the power set P(S), of cardinality 2^|S| . Thus, a large number of categories makes question selection computationally intractable. "
Q1 -> How is the possible set of questions is 2^|S| ? It should be equal to the non-leaf nodes in the decision tree .
Link to Andrew Ng notes on Decision Tree : http://cs229.stanford.edu/notes/cs229-notes-dt.pdf
Can you please give some clarification on it .
machine-learning decision-trees
New contributor
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
I was going through the Andrew Ng's notes for Decision Trees. It has one section explaining the usage of categorical variables using Decision Trees in which I am not able to understand this part
" A caveat to the above is that we must take care to not allow a variable
to have too many categories. For a set of categories S, our set of possible
questions is the power set P(S), of cardinality 2^|S| . Thus, a large number of categories makes question selection computationally intractable. "
Q1 -> How is the possible set of questions is 2^|S| ? It should be equal to the non-leaf nodes in the decision tree .
Link to Andrew Ng notes on Decision Tree : http://cs229.stanford.edu/notes/cs229-notes-dt.pdf
Can you please give some clarification on it .
machine-learning decision-trees
machine-learning decision-trees
New contributor
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked yesterday
Pankaj KumarPankaj Kumar
112
112
New contributor
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Pankaj Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
The $2^{|S|}$ number of POSSIBLE questions is defined by the number of different combinations of subsets of $S$ that could be part of the first partitions, then the second and so on until the tree is finished. That being the worst case.
Imagine that: $loc in{} N$ is the first separation, so it's divided into Yes/No. Then $loc in{} S$ is divided into Yes/No.
Then $loc in{} E$ is the third partition and the answer is the same (Yes/No), you have 8 (2^3) questions asked. There are many combinations of use/no use/which to combine in which step, etc, but ultimately you will be asking the tree to consider all possibilities, which are $2^{card(S)}$.
New contributor
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
The author is referring to the number of possible splits of the given node, by the given feature during the building of the tree. The tree can send any subset of the levels to the left, and the remaining levels to the right. (Well, actually the left/right symmetry means the number of options is cut in half, and there's no point in sending the empty set vs. the full set, so the real number of choices is $2^{|S|-1}-1$, but the point remains that categorical variables with many levels are problematic.)
Compare to a continuous or ordinal variable, where the sort of splits we consider are only $xleqalpha$ vs. $x>alpha$, and $alpha$ need only range over the number of levels $|S|-1$ (again $-1$ to ignore sending nothing vs. everything).
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "557"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Pankaj Kumar is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f49203%2fcategorical-variables-in-decision-tree%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The $2^{|S|}$ number of POSSIBLE questions is defined by the number of different combinations of subsets of $S$ that could be part of the first partitions, then the second and so on until the tree is finished. That being the worst case.
Imagine that: $loc in{} N$ is the first separation, so it's divided into Yes/No. Then $loc in{} S$ is divided into Yes/No.
Then $loc in{} E$ is the third partition and the answer is the same (Yes/No), you have 8 (2^3) questions asked. There are many combinations of use/no use/which to combine in which step, etc, but ultimately you will be asking the tree to consider all possibilities, which are $2^{card(S)}$.
New contributor
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
The $2^{|S|}$ number of POSSIBLE questions is defined by the number of different combinations of subsets of $S$ that could be part of the first partitions, then the second and so on until the tree is finished. That being the worst case.
Imagine that: $loc in{} N$ is the first separation, so it's divided into Yes/No. Then $loc in{} S$ is divided into Yes/No.
Then $loc in{} E$ is the third partition and the answer is the same (Yes/No), you have 8 (2^3) questions asked. There are many combinations of use/no use/which to combine in which step, etc, but ultimately you will be asking the tree to consider all possibilities, which are $2^{card(S)}$.
New contributor
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
The $2^{|S|}$ number of POSSIBLE questions is defined by the number of different combinations of subsets of $S$ that could be part of the first partitions, then the second and so on until the tree is finished. That being the worst case.
Imagine that: $loc in{} N$ is the first separation, so it's divided into Yes/No. Then $loc in{} S$ is divided into Yes/No.
Then $loc in{} E$ is the third partition and the answer is the same (Yes/No), you have 8 (2^3) questions asked. There are many combinations of use/no use/which to combine in which step, etc, but ultimately you will be asking the tree to consider all possibilities, which are $2^{card(S)}$.
New contributor
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
The $2^{|S|}$ number of POSSIBLE questions is defined by the number of different combinations of subsets of $S$ that could be part of the first partitions, then the second and so on until the tree is finished. That being the worst case.
Imagine that: $loc in{} N$ is the first separation, so it's divided into Yes/No. Then $loc in{} S$ is divided into Yes/No.
Then $loc in{} E$ is the third partition and the answer is the same (Yes/No), you have 8 (2^3) questions asked. There are many combinations of use/no use/which to combine in which step, etc, but ultimately you will be asking the tree to consider all possibilities, which are $2^{card(S)}$.
New contributor
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered yesterday
Juan Esteban de la CalleJuan Esteban de la Calle
687
687
New contributor
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
$begingroup$
The author is referring to the number of possible splits of the given node, by the given feature during the building of the tree. The tree can send any subset of the levels to the left, and the remaining levels to the right. (Well, actually the left/right symmetry means the number of options is cut in half, and there's no point in sending the empty set vs. the full set, so the real number of choices is $2^{|S|-1}-1$, but the point remains that categorical variables with many levels are problematic.)
Compare to a continuous or ordinal variable, where the sort of splits we consider are only $xleqalpha$ vs. $x>alpha$, and $alpha$ need only range over the number of levels $|S|-1$ (again $-1$ to ignore sending nothing vs. everything).
$endgroup$
add a comment |
$begingroup$
The author is referring to the number of possible splits of the given node, by the given feature during the building of the tree. The tree can send any subset of the levels to the left, and the remaining levels to the right. (Well, actually the left/right symmetry means the number of options is cut in half, and there's no point in sending the empty set vs. the full set, so the real number of choices is $2^{|S|-1}-1$, but the point remains that categorical variables with many levels are problematic.)
Compare to a continuous or ordinal variable, where the sort of splits we consider are only $xleqalpha$ vs. $x>alpha$, and $alpha$ need only range over the number of levels $|S|-1$ (again $-1$ to ignore sending nothing vs. everything).
$endgroup$
add a comment |
$begingroup$
The author is referring to the number of possible splits of the given node, by the given feature during the building of the tree. The tree can send any subset of the levels to the left, and the remaining levels to the right. (Well, actually the left/right symmetry means the number of options is cut in half, and there's no point in sending the empty set vs. the full set, so the real number of choices is $2^{|S|-1}-1$, but the point remains that categorical variables with many levels are problematic.)
Compare to a continuous or ordinal variable, where the sort of splits we consider are only $xleqalpha$ vs. $x>alpha$, and $alpha$ need only range over the number of levels $|S|-1$ (again $-1$ to ignore sending nothing vs. everything).
$endgroup$
The author is referring to the number of possible splits of the given node, by the given feature during the building of the tree. The tree can send any subset of the levels to the left, and the remaining levels to the right. (Well, actually the left/right symmetry means the number of options is cut in half, and there's no point in sending the empty set vs. the full set, so the real number of choices is $2^{|S|-1}-1$, but the point remains that categorical variables with many levels are problematic.)
Compare to a continuous or ordinal variable, where the sort of splits we consider are only $xleqalpha$ vs. $x>alpha$, and $alpha$ need only range over the number of levels $|S|-1$ (again $-1$ to ignore sending nothing vs. everything).
answered yesterday
Ben ReinigerBen Reiniger
347210
347210
add a comment |
add a comment |
Pankaj Kumar is a new contributor. Be nice, and check out our Code of Conduct.
Pankaj Kumar is a new contributor. Be nice, and check out our Code of Conduct.
Pankaj Kumar is a new contributor. Be nice, and check out our Code of Conduct.
Pankaj Kumar is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f49203%2fcategorical-variables-in-decision-tree%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown