0
votes

I'm using weka to train my insurance data to get the classify rules, I choose Jrip and J48(C4.5 decision tree) by using weka java api and get rule like(age > 18) => class=1. Is there any way that I can get weka result and transfrom it into LHS(left-hand-side) of drools rule expression?

1

1 Answers

0
votes

For J48 there are 3 ways to output generated tree. In each version you need to parse the output and construct your expressions.

J48 cls = new J48();
...
cls.buildClassifier(instances);
  1. cls.toString() returns build tree as string. You need to parse between "J48 pruned tree" and "Number of Leaves"
  2. cls.toSource(className) Returns tree as an if-then statement.
  3. cls.graph() returns build tree in dotty format