Classification using random forest and Weka
Code: "weka_random_forest.py". Programming language: Python
DMelt Version 2.2. Last modified: 03/03/2021. License: Pro
https://datamelt.org/code/cache/weka_random_forest_8343.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 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)
print data
from weka.classifiers.trees import RandomForest
rt = RandomForest()
print rt.globalInfo()
rt.buildClassifier(data)
print rt
You see the box below because you did not login.