1

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:

Housing Prices

Ideally, I would like to perform these operations:

  1. retrieve the row names for the observations that are in the nodes at the bottom
  2. 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
Jealie
  • 6,157
  • 2
  • 33
  • 36
GreenManXY
  • 401
  • 1
  • 5
  • 14
  • It looks like [this answer](http://stackoverflow.com/questions/29304349/how-to-get-terminal-nodes-for-a-new-observation-from-an-rpart-object/29328690#29328690) shows how to do something very similar. – Jealie Apr 19 '17 at 21:47
  • I'm looking at the party package but I'm not seeing how I can use it to create the plot that I want. I'm quite new to R so maybe I'm missing something. – GreenManXY Apr 20 '17 at 19:39

0 Answers0