"Hooks in operators - extension of existing operators"

bondtntbondtnt Member Posts: 7 Contributor II
edited June 2019 in Help
Hello everybody,

I have 2 questions regarding extension of existing operators:

1) I need to persist performance operator result into the DB. I guess this can be done by persisting PerformanceVector object, is it correct? Currently I've implemented it by extending Performance operator, but I'm not particularly happy with the solution.
2) I need to persist correct/wrong classifications (done in Performance operator) along with input data (Example object) attribute in the DB. What would be the best way to do this? I've digged RM src a bit and found no meaningful way on how to place hooks in appropriate places, extension of Performance related classes looks very ugly solution, while some CGLIB magic seems not so possible as I'm not sure I'll be able to replace original objects with proxies, while ByteCodeInstrumentation is an overkill. Any solutions/suggestions, maybe I've overlooked something?

Best regards,
Andrey

Answers

  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    Hi,

    instead of extending the performance operator, you should create a new operator which gets a Performance Vector IOObject as input and writes it to the database.

    2) What exactly do you mean? Do you simply want to store if a prediction is correct? Maybe the Generate Attributes operator is useful for you. See the attached process.

    Best, Marius
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.002">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.002" expanded="true" name="Process">
        <process expanded="true" height="638" width="748">
          <operator activated="true" class="generate_data" compatibility="5.2.002" expanded="true" height="60" name="Generate Data" width="90" x="112" y="30">
            <parameter key="target_function" value="random classification"/>
          </operator>
          <operator activated="true" class="naive_bayes" compatibility="5.2.002" expanded="true" height="76" name="Naive Bayes" width="90" x="246" y="30"/>
          <operator activated="true" class="apply_model" compatibility="5.2.002" expanded="true" height="76" name="Apply Model" width="90" x="380" y="30">
            <list key="application_parameters"/>
          </operator>
          <operator activated="true" class="rename_by_replacing" compatibility="5.2.002" expanded="true" height="76" name="Rename by Replacing" width="90" x="514" y="30">
            <parameter key="include_special_attributes" value="true"/>
            <parameter key="replace_what" value="\(|\)"/>
            <parameter key="replace_by" value="_"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="5.2.002" expanded="true" height="76" name="Generate Attributes" width="90" x="648" y="30">
            <list key="function_descriptions">
              <parameter key="correct_prediction" value="label==prediction_label_"/>
            </list>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Naive Bayes" to_port="training set"/>
          <connect from_op="Naive Bayes" from_port="model" to_op="Apply Model" to_port="model"/>
          <connect from_op="Naive Bayes" from_port="exampleSet" to_op="Apply Model" to_port="unlabelled data"/>
          <connect from_op="Apply Model" from_port="labelled data" to_op="Rename by Replacing" to_port="example set input"/>
          <connect from_op="Rename by Replacing" from_port="example set output" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" 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"/>
        </process>
      </operator>
    </process>
Sign In or Register to comment.