I am trying to obtain the number of occurrences a decision tree path is used to classify an instance.
For example, suppose I have the following rules (not sure if they make sense):
- Rule 1: [x<3 and y<5 => 'Low']
- Rule 2: [x<3 and x>1 and y<5 => 'Low']
- Rule 3: [x<3 and y>2 and y<5 => 'Low']
- Rule 4: [x<6 and y<8 => 'Medium']
- Rule 5: [x<10 and y<10 => 'High']
Now, suppose I have 10 test set samples. I want something like this given this test set and the above rules:
- Rule 1 has been used 2 times,
- Rule 2 has been used 2 times,
- Rule 3 has been used 1 times,
- Rule 4 has been used 3 times,
- and Rule 5 has been used 2 times
How to tackle this using Python?