Classification of data using M5P from Weka
Code: "weka_classification_m5p.py". Programming language: Python
DMelt Version 2.29. Last modified: 03/03/2021. License: Pro
https://datamelt.org/code/cache/weka_classification_m5p_7045.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 java.util import Random
from weka.classifiers.trees import M5P
from weka.classifiers import Evaluation
from jhplot import Web
# load data
xf="bolts.arff"
url="https://datamelt.org/examples/data/weka/regression/"+xf
print "Loading ",xf
print Web.get(url)
data = Instances(FileReader(xf))
data.setClassIndex(data.numAttributes() - 1)
cls = M5P()
xval = Evaluation(data);
xval.crossValidateModel(cls, data, 10, Random(1))
print xval.toSummaryString()
You see the box below because you did not login.