Generating a decision tree using J48 algorithm

2.4k Views Asked by At

I want to create a GUI using NetBeans and using the WEKA library. One button to upload an arff file that contains the data and another to generate a decision tree using J48 algorithm. All the tutorials online shows how to generate using the WEKA explorer but how can I do this in our GUI?

1

There are 1 best solutions below

0
On

So you are trying to build a classifier programatically without the weka explorer?

This will build your classifier:

Reader r = new FileReader("/path/to/file.arff");

Instances i = new Instances(r);

Classifier c = new J48();
c.buildClassifier(i);

The necessary imports are:

import weka.classifiers.Classifier;
import weka.classifiers.trees.J48;
import weka.core.Instances;

The only thing your GUI has to do is to provide the path to the ARFF file.

I hope this will answer your question.