Data classification using Weka with J48 algorithm
Code: "weka_classification48.py". Programming language: Python
DMelt Version 2.29. Last modified: 03/03/2021. License: Free
https://datamelt.org/code/cache/weka_classification48_4760.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="https://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)