The classic decision-tree algorithm would split a branch based on the value of a variable versus a number. For example, if x > 0.5: branch_left; else: branch_right. What I need is a decision-tree-like algo able to split the branches also by comparing a variable with another variable (both features), for example if x > y: branch_left; else: branch_right. I have looked into the various implementation of the decision-tree and random-forest algos (mostly in Python) and I couldn't find any able to do as much.

Do you know if such an algorithm exists already? Can you suggest one I could try?

  • $\begingroup$ Would constructing linear combinations of variables suffice? For you example, you could derive a feature like $x - y$ and find a cut point for that difference. $\endgroup$ – Fato39 Sep 7 at 11:58
  • 1
    $\begingroup$ x and y vary a lot in my case, so the result of x - y wouldn't be so helpful, rather the fact that x is greater or lower than y would help. Of course, I could do the computation in advance and then just make an extra feature column in the dataset to output the result of the comparison. I would prefer to find an algorithm that does that automatically though since the combination of variables could be quite large. $\endgroup$ – alec_djinn Sep 7 at 12:08

What you are asking for comes from simple feature engineering before you launch the algorithm. If you about the specific relationship about two features, you should create features about their linear relationship (x-y, in your case) or non-linear (x*y, or x/y, for example).

Otherwise, as far as I know, there is no "readily available" version of decision trees that does what you ask for.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.