3
$\begingroup$

I am using MST function from MST (multivariate survival tree) package in R to train survival tree. However when I want to predict the node for one selected observation, the output is different. I have not changed the code, just ran the same rows multiple times. I am using the tree selected as the best tree when penalty log_n is used, see documentation (TLDR: n is number of out of bootstrap samples, but the tree is already selected and does not change during prediction). There is no factor issue, as suggested by other answers. Any idea what could be wrong?

$\endgroup$
3
  • $\begingroup$ What happens when you run set.seed(15) beforehand ? $\endgroup$ – Robert Long Aug 5 '20 at 8:40
  • $\begingroup$ looks like it stays the same, something must be random in the prediction of decision tree. it does not make sense to me, when the final tree does not change anymore $\endgroup$ – pikachu Aug 5 '20 at 8:41
  • $\begingroup$ I also do not have any missing values, which are sometimes treated randomly in DT model... $\endgroup$ – pikachu Aug 5 '20 at 8:43
3
$\begingroup$

I don't know what that function is doing specifically (questions specific to software are off topic here anyway) but from your description (eg bootstrap, or random sampling relating to the treatment of missing values) then there will be some random sampling happening. Therefore setting a seed for the randon number generator prior to running the code should ensure repeatability. Just because the final tree doesn't change doesn't mean that the exact same process has created it - you can think of the final tree in this case as a "limiting value" which will be obtained every time for the parameters that you choose when you run it.

$\endgroup$
4
  • $\begingroup$ but I have problems in prediction, which is based on the fixed final tree. Sorry, I just realized the question is offtopic and should be on stack overflow, how can I migrate it there? $\endgroup$ – pikachu Aug 5 '20 at 8:56
  • $\begingroup$ You need to ask a new question on SO and make it more focussed. I have answered the question that you asked here (about why you get different values from the same code). $\endgroup$ – Robert Long Aug 5 '20 at 8:58
  • $\begingroup$ Sorry, I have found out where is the problem. I have one categorical variable which has many levels. However for the split only part of those levels were used and if the observation has different value it is treated as "missing" and in prediction process decides randomly. It has nothing to do with bootstrap, that is used only in training process. $\endgroup$ – pikachu Aug 5 '20 at 9:05
  • $\begingroup$ So my answer still applies. Something random was happening, and you can fix that by setting the seed. $\endgroup$ – Robert Long Aug 5 '20 at 9:07
0
$\begingroup$

I have figured it out. I have one categorical variable which has many levels. However for the split only part of those levels were used and if the observation has different value it is treated as "missing" and in prediction process decides randomly. Thus the observation is sent to left or right way randomly, if the level is not used in split.

$\endgroup$

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.