How to subtract a value from the predicted value in a models decision tree? I'm using rpart
to create a model of housing prices and it produces a predicted price at every node/leaf:
Ideally, I would like to perform these operations:
- retrieve the row names for the observations that are in the nodes at the bottom
- calculate the mean value and then subtract the mean in the model. The reason is that I would like to get the difference in actual price in the bottom nodes and not just the predicted price.
My training data looks something like this (from the Kaggle competition):
Id, LivingArea, GarageArea,..., SalePrice
1, 1200, 500, ..., 50 000
2, 500, 1500, ..., 150 000