I am trying to apply the j48 classifier on a dataset, but I am not understanding how to actually select the right attribute as the class. I found a method called class_is_last() which sets the last attribute as the class, but what if I want to select my attribute called say 'name' as the class?
jvm.start()
loader = Loader(classname="weka.core.converters.ArffLoader")
dataweka = loader.load_file("enumeratedremovedtest-arff.arff")
dataarff = arff.load(open('enumeratedremovedtest-arff.arff', 'rb'))
from weka.classifiers import Classifier
dataweka.class_is_last()
cls = Classifier(classname="weka.classifiers.trees.J48", options=["-C","0.25", "-B", "-M", "2"])
print dataweka.class_attribute
cls.build_classifier(dataweka)
print(cls)
jvm.stop()
All required modules have been imported, and this works as expected and uses the last attribute in the list as the class.