How to set class counter / probability threshold for marking "predicted class" in R rpart

I am using the rpart function to get a decision tree to predict Owner / No Owner based on a set of variables. Below is an excerpt from the output

Node number 2: 8 observations,    complexity param=0.08333333   predicted class=non-owner  expected loss=0.125  P(node) =0.3333333
class counts:     7     1    probabilities: 0.875 0.125 

      

From the above output, you can see that Node 2 is marked as the predicted class "Non-owner" because the number of classes (probability 0.875) is 7 for the non-owner in that node. I want to change the default threshold based on which Node. To clarify, assuming the default value is 0.5 - if the probability (the number of non-owner classes is more than half of the data points) is> 0.5, then Node is designated as non-owner, but I want to change that value to 0.9 t .e. only if the number of non-owner class members is more than 9 out of 10 (ratio), Node should be marked as non-owner, otherwise the owner.

+3
r decision-tree rpart


source to share


No one has answered this question yet

Check out similar questions:

4
Forecasting data using rpart decision tree
4
Using the survival tree from the "rpart" package in R to predict new observations
2
Get all functions in a solution path to a leaf node (Random Forest)
1
detecting observations at each node
1
How to interpret xerror rpart (method = "class") when assigning losses
1
RPART explains forecast output for type matrix
0
Extract variable labels from rpart decision tree
0
How to change the prediction FALSE vs TRUE
0
Tree pruning
-1
Find a column number that satisfies a condition based on another vector



All Articles
Loading...
X
Show
Funny
Dev
Pics