Search code examples
wekaj48

how to classify using j48 weka with information gain and random attribute selection?


I know that j48 decision tree uses gain ratio to select attribute for making tree. But i want to use information gain and random selection instead of gain ratio. In select attribute tab in Weka Explorer, I choose InfoGainAttributeEval and put start button. After that I see the sorted list of attribute with information gain method. But I don't know how to use this list to run j48 in Weka. Moreover I don't know how to select attribute randomly in j48. Please help me if you can.


Solution

  • If you want to perform feature selection on the data before running the algorithm you have two options:

    1. In the Classify tab use AttributeSelectedClassifier (under the meta folder). There you can configure the feature selection algorithm you want. (The default is J48 with CfsSubsetEval).

    2. In the Preprocess tab find and apply AttributeSelect filter (located at supervised\attribute folder). The default here is also the CfsSubsetEval algorithm.

    Notice that the first method will apply the algorithm only on the train set when you'll evaluate the algorithm, while the second method will use the entire dataset and will remove features that were not selected (you can use undo to bring them back).

    Notice that the way J48 selects features during the training process will remain the same. To change it you need to implement your own algorithm or change the current implementation.