Forced Decision Trees

I used decision trees (CART) in R, using the rpart package to look at the relationship between SST (predictor variables) and climate (predand variable).

I would like to โ€œforceโ€ the tree into a specific structure, i.e. split into predictor variable 1, then into variable 2.

I used R for a while, so I thought I could look at the code behind the rpart function and change it first to look for the โ€œbest splitsโ€ in a specific forecast variable first. However, the rpart function calls C-procedures and has no experience with C, I get lost here ...

I could write a function from scratch, but would like to avoid it if possible! So my questions are:

  • Is there another decision tree technology (implemented in R preferably) in which you can force the tree structure?
  • If not, is there a way to convert the C code to R?
  • Any other ideas?

Thanks in advance and help is greatly appreciated.

+4
source share
2 answers

When your data indicates a tree with a known structure, represent this structure in R using either the new or the nexus file format. You can then read in the structure using read.tree or read.nexus from the Phylo package.

+1
source

Perhaps you should look at the formal parameter method rpart

In the documentation:

... 'may be a list of functions named init, split and eval. Examples are given in the file 'tests / usersplits.R in the sources.

0
source

Source: https://habr.com/ru/post/1396564/


All Articles