2
$\begingroup$

I have operational fault data and maintenance data. The operational fault data was used to determine if the maintenance improved the fault indicator (true/false). The maintenance data was used to identify what maintenance actions were performed. RPART was used to generate a model, with the maintenance actions as independent variables and operational fault reduction as the categorical output data (true/false). 0.5 was subtracted from the operational fault data so the values were -0.5, 0.5 instead of 0, 1.

I don't understand how to interpret the meaning of the plot of the rtree model. How to determine, or indicate, which of the bottom nodes correspond to true or false? Also, what do the colors indicate.

R commands

subdata <- data.frame(x="maintenance actions", y="Fault improved"-0.5)
rtreeFit <- rpart(y ~ .,data=subdata)
fancyRpartPlot(rtreeFit,main=paste('RPART:'),sub=cName)

Is it possible to draw a histogram for each leaf showing the distribution of classifications?

enter image description here

Here's the updated code

y_subdata = factor(y_training[rowIndx])
x_subdata = x_training[rowIndx, ]
subdata<-data.frame(x=x_subdata,y=y_subdata)
fit <- rpart(y ~ .,method='class',data=subdata,
             control=rpart.control(minsplit=3,cp=0.0001))

The numbers are hard to read, but what do the numbers mean?

enter image description here

$\endgroup$
1
$\begingroup$

One thing that concerns me is the way that at least 2 of the variables show up at multiple nodes. I have run a lot of Recursive partitioning using RPART and have come to recognize multiple nodes with the same variable as a sign that the tree may be unreliable (e.g., nodes 1, 3, and 11 are both "x.sum_manhours"). I am not sure why you subtracted 0.5 from your operational fault outcome variable. It seems like this was an attempt to center the data but your outcome is a categorical or factor variable so centering means nothing. By subtracting 0.5 your program may have treated your outcome variable as continuous which would mean that your RPART procedure created a regression tree (continuous outcome) instead of a classification tree (categorical outcome). Finally, there are bootstrapping techniques for checking the stability of your tree that you might consider.

$\endgroup$
  • 1
    $\begingroup$ Welcome to the site, @Davester. This doesn't really answer the OP's explicit questions, but does seem like good information. Why not add some info about how to read the plot & whether it would be possible / make sense to create a histogram for each terminal node? Re the unreliability you mention here, is that b/c CART assumes every variable interacts w/ every variable & when the same var shows up in multiple nodes it implies that such interactions don't actually exist in your data? $\endgroup$ – gung - Reinstate Monica Dec 10 '14 at 18:15
  • $\begingroup$ On a different note, why not register your account & take our tour to join the site more formally? It'll be nice to have you around. $\endgroup$ – gung - Reinstate Monica Dec 10 '14 at 18:17
  • 1
    $\begingroup$ There is not necessarily a problem if a variable appears in multiple decisions. It could only mean it is an important predictor. $\endgroup$ – Michael M Dec 10 '14 at 18:19
  • $\begingroup$ The presence of values between -.5 and +.5 in his terminal nodes along the bottom of the diagram strongly indicates that he ran a regression tree and that his outcome variable was treated as continuous when it is actually dichotomous (i.e., true/false). I say use the original 0 (false) and 1 (true) and check with > class(y) to make sure it is a factor. Until this is done correctly (assuming it currently is incorrect) there is nothing worth reading from the tree. $\endgroup$ – Davester Dec 10 '14 at 20:08
  • $\begingroup$ I forgot to add that when using rpart the code should have [method="class"] added after [~.,] to ensure that a classification tree with a categorical outcome is being created. $\endgroup$ – Davester Dec 10 '14 at 20:26

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.