This code
data(ptitanic)
model <- rpart(survived ~ ., data = ptitanic, cp = .02)
rules <- rpart.rules(model)
prints the leaves of the tree as follows
survived
0.05 when sex is male & age < 9.5 & sibsp >= 3
0.17 when sex is male & age >= 9.5
0.73 when sex is female
0.89 when sex is male & age < 9.5 & sibsp < 3
The tree is the following:
The first column, survived, contains the percentage that we see shown in the center of each leaf. Instead, I would like to have the another column with the remaining percentage, i.e. the one that appears in the lower part of each leaf. Meaning what:
0.02 0.05 when sex is male & age < 9.5 & sibsp >= 3
0.61 0.17 when sex is male & age >= 9.5
0.36 0.73 when sex is female
0.02 0.89 when sex is male & age < 9.5 & sibsp < 3
