I have created a huge j48 tree of size around 7000 with so many branches and leaves. I am getting classification result as well for test images. I would like to know which of the node is making the classification for each result. In other words, Is there a way with weka to see the id or something of the leaf node that makes the decision.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
As far as I know, you will not be able to do this from the Weka GUI. However, if you use the Weka API there is some hope. I am not an expert in Java, so the following steps may not follow the best practice, but it does work for the small example I concocted.
Build the j48 tree in the Weka GUI and in the "more options" tab select "Output Source Code"
Copy the source code to a new class in your Java code
In the classifyInstance method augment the return variable to include a leaf number
Modify the class so it no longer extends "Classifier" (this requires eliminating a few other methods in the class you just created)
Below is a class that will classify a Weka Instance with a decision stump classifier. The output will include a leaf number. This was built from the categorical weather data included in the Weka example datasets by following the above steps. For the huge decision tree you have it may be necessary to do some string replacement to efficiently augment your return variable.