Data classification using Weka with J48 algorithm
Source code name: "weka_classification48.py"
Programming language: Python
Topic: Data mining/Classification
DMelt Version 2.29. Last modified: 10/28/2018. License: Free
http://datamelt.org/code/cache/weka_classification48_8344.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


from java.io import FileReader
from weka.core import Instances
from weka.classifiers.trees import J48

from jhplot import Web
xf="iris.arff"
url="http://datamelt.org/examples/data/weka/"+xf
print "Loading ",xf
print Web.get(url)

ifile = FileReader(xf)
data = Instances(ifile)
data.setClassIndex(data.numAttributes() - 1)
j=J48()
j.buildClassifier(data)
print(j)