I have trained decision tree . I also have a graph of the tree ( ) . Now i want to see which samples (red circled ones ) are under which leafs . I am using sklearn's implantation . Is there any way to get the samples under a leaf ? ?
For me, the easiest way would be to find the leaves where each sample belongs and then split the dataframe into clusters using
iloc, to further analyse the clusters. This can be done using:
Use the apply function on the fitted model.
See in Documents.
The mentioned leaf-index as the same as in the underlining _tree object(used for visualization).