How to log the size of W-J48 Tree?

wesselwessel Member Posts: 537 Maven
edited November 2018 in Help
Dear All,

How can I log the value of the the size of W-J48 Tree?


Number of Leaves  : 7
Size of the tree : 13

Best regards,



  • Options
    Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,996 RM Engineering

    I fear that you will need the "Execute Script" operator. Please see the following process for an example:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.0.004">
      <operator activated="true" class="process" compatibility="6.0.004" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="retrieve" compatibility="6.0.004" expanded="true" height="60" name="Retrieve Golf" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Golf"/>
          <operator activated="true" class="weka:W-J48" compatibility="5.3.001" expanded="true" height="76" name="W-J48" width="90" x="179" y="30"/>
          <operator activated="true" class="execute_script" compatibility="6.0.004" expanded="true" height="76" name="Execute Script" width="90" x="313" y="30">
            <parameter key="script" value="import com.rapidminer.operator.learner.weka.WekaClassifier;&#10;import weka.classifiers.trees.J48;&#10;import com.rapidminer.tools.LogService;&#10;import java.util.logging.Level;&#10;&#10;WekaClassifier classifier = (WekaClassifier)input[0];&#10;J48 j48 = classifier.getClassifier();&#10;LogService.getRoot().log(Level.INFO, &quot;WEKA TREE SIZE: &quot;+j48.measureTreeSize());&#10;LogService.getRoot().log(Level.INFO, &quot;WEKA LEAF NUMBER: &quot;+j48.measureNumLeaves());&#10;&#10;return input[0];"/>
          <connect from_op="Retrieve Golf" from_port="output" to_op="W-J48" to_port="training set"/>
          <connect from_op="W-J48" from_port="model" to_op="Execute Script" to_port="input 1"/>
          <connect from_op="Execute Script" from_port="output 1" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
  • Options
    wesselwessel Member Posts: 537 Maven
    Thanks a million Marco!

Sign In or Register to comment.