2
$\begingroup$

Could anyone kindly give some practical advice on how to deal with predictors of a range of values?

For instance, I want to predict $Y$ based on features $X_{i}, \ i=1,2,...,N$. Some $X_{i}$s are of the form: $X_{i} \in [3,5]$ (ranges from 3 to 5) or $X_{j} \in \{2,3\} $. How would the decision tree learn where to split in between those integer ranges? In my particular application, these are all ranges of integer values. But advice on how to deal with real value ranges is appreciated too!

Follow-up: what formats would you advise to process such variables into when using, for instance, rpart package of R or sklearn from python? Do you simply discretize them into a matrix of binary variables, or better?

More follow-up: I am not asking how to process continuous or ordinal variables --- I already know that. I am asking how to preprocess instances of the form of a particular range. For instance,

id variable_x

0 3

1 [2,5]

2 {2,4}

3 [4,5]

Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$

As far as I know, in case of a decision tree model, it doesn't matter whether the variables are continuous or discrete. In any case, it tries to get the optimal split at any node (for any variable) so as to create an optimal set of decision rules for the correct prediction. In case of a discrete variable $X_{j} \in \{1,2,3,4\}$, the split could be of the form $\{1\}, \{2,3,4\}$ whereas in case of ordinal variables $X_i \in [3,5]$ the splits are of the form $\{x : 3<=x<4.2\}\{x : 4.2<=x<=5\} $ but the goal and method is generally the same in both cases.

$\endgroup$
4
  • $\begingroup$ I agree... Excuse my follow-up but let me clarify a bit: practically speaking, what formats do you process such variables into when using, for instance, rpart package of R? Do you discretize them? $\endgroup$
    – shenglih
    Commented May 20, 2018 at 18:41
  • $\begingroup$ No. There's no need to discretize the variable. It creates the split in the same way I mentioned. Decision tree also doesn't require scaling/normalization before usage. $\endgroup$ Commented May 20, 2018 at 18:51
  • $\begingroup$ You can take a look at rpart's manual: cran.r-project.org/web/packages/rpart/vignettes/longintro.pdf In page 10, for the given example you can see that they treat the categorical (ploidy, pstat) and ordinal (g2, pgtime) variables in the same way without any other preprocessing step. $\endgroup$ Commented May 20, 2018 at 18:53
  • $\begingroup$ Hi Satwik, thanks for your help so far... but I think you misunderstook my question... Please see follow-ups... Thanks all the same :D $\endgroup$
    – shenglih
    Commented May 20, 2018 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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