python - Get probability of classification from decision tree -


i'm implementing decision tree based on cart algorithm , have question. can classify data, task not classify data. want have probability of right classification in end nodes. example. have dataset contains data of classes , b. when put instance of class tree want see probability instance belongs class , class b. how can that? how can improve cart have probability distribution in end nodes?

when train tree using training data set, every time split on data, left , right node end proportion of instances class , class b. percentage of instances of class (or class b) can interpreted probability.

for example, assume training data set includes 50 items class , 50 items class b. build tree of 1 level, splitting data once. assume after split, left node ends having 40 instances of class , 10 instances of class b , right node has 10 instances of class , 40 instances of class b. probabilities in nodes 40/(10+40) = 80% class in left node, , 10/(10+40) = 20% class in left node (and vice versa class b).

exactly same applies deeper trees: count instances of classes , compute proportion.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -