Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

Save results of Optimize Parameter operator using macros

aryan_hosseinzaaryan_hosseinza Member Posts: 74 Contributor II
edited June 2019 in Help
Hi everybody ,

I want to save result of each combination of parameter values in separate files , I know I have to use macros , but I don't know how to use it here ,

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.008">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.2.008" expanded="true" name="Process">
    <process expanded="true" height="494" width="1016">
      <operator activated="true" class="generate_massive_data" compatibility="5.2.008" expanded="true" height="60" name="Generate Massive Data" width="90" x="112" y="75">
        <parameter key="number_examples" value="1000"/>
        <parameter key="number_attributes" value="100"/>
        <parameter key="sparse_fraction" value="0.95"/>
      </operator>
      <operator activated="true" class="nominal_to_binominal" compatibility="5.2.008" expanded="true" height="94" name="Nominal to Binominal" width="90" x="313" y="75">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="label"/>
        <parameter key="include_special_attributes" value="true"/>
      </operator>
      <operator activated="true" class="optimize_parameters_grid" compatibility="5.2.008" expanded="true" height="94" name="Optimize Parameters (Grid)" width="90" x="514" y="75">
        <list key="parameters">
          <parameter key="Select by Weights.k" value="[10;40;5;linear]"/>
          <parameter key="W-ReliefFAttributeEval.K" value="[5;45;10;linear]"/>
        </list>
        <process expanded="true" height="649" width="1094">
          <operator activated="true" class="weka:W-ReliefFAttributeEval" compatibility="5.1.001" expanded="true" height="76" name="W-ReliefFAttributeEval" width="90" x="179" y="30">
            <parameter key="sort_direction" value="descending"/>
            <parameter key="K" value="45.0"/>
          </operator>
          <operator activated="true" class="select_by_weights" compatibility="5.2.008" expanded="true" height="94" name="Select by Weights" width="90" x="380" y="30">
            <parameter key="weight_relation" value="top k"/>
            <parameter key="weight" value="0.0"/>
            <parameter key="k" value="40"/>
          </operator>
          <operator activated="true" class="x_validation" compatibility="5.2.008" expanded="true" height="112" name="Validation" width="90" x="514" y="30">
            <process expanded="true" height="649" width="522">
              <operator activated="true" class="naive_bayes" compatibility="5.2.008" expanded="true" height="76" name="Naive Bayes" width="90" x="216" y="30"/>
              <connect from_port="training" to_op="Naive Bayes" to_port="training set"/>
              <connect from_op="Naive Bayes" from_port="model" to_port="model"/>
              <portSpacing port="source_training" spacing="0"/>
              <portSpacing port="sink_model" spacing="0"/>
              <portSpacing port="sink_through 1" spacing="0"/>
            </process>
            <process expanded="true" height="649" width="522">
              <operator activated="true" class="apply_model" compatibility="5.2.008" expanded="true" height="76" name="Apply Model" width="90" x="45" y="30">
                <list key="application_parameters"/>
              </operator>
              <operator activated="true" class="performance_binominal_classification" compatibility="5.2.008" expanded="true" height="76" name="Performance" width="90" x="283" y="30">
                <parameter key="accuracy" value="false"/>
                <parameter key="AUC" value="true"/>
                <parameter key="f_measure" value="true"/>
                <parameter key="false_positive" value="true"/>
                <parameter key="false_negative" value="true"/>
                <parameter key="true_positive" value="true"/>
                <parameter key="true_negative" value="true"/>
              </operator>
              <connect from_port="model" to_op="Apply Model" to_port="model"/>
              <connect from_port="test set" to_op="Apply Model" to_port="unlabelled data"/>
              <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
              <connect from_op="Performance" from_port="performance" to_port="averagable 1"/>
              <portSpacing port="source_model" spacing="0"/>
              <portSpacing port="source_test set" spacing="0"/>
              <portSpacing port="source_through 1" spacing="0"/>
              <portSpacing port="sink_averagable 1" spacing="0"/>
              <portSpacing port="sink_averagable 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="write_as_text" compatibility="5.2.008" expanded="true" height="76" name="Write as Text" width="90" x="782" y="30">
            <parameter key="result_file" value="/home/arian/result%{x1}_%{x2}.res"/>
          </operator>
          <connect from_port="input 1" to_op="W-ReliefFAttributeEval" to_port="example set"/>
          <connect from_op="W-ReliefFAttributeEval" from_port="weights" to_op="Select by Weights" to_port="weights"/>
          <connect from_op="W-ReliefFAttributeEval" from_port="example set" to_op="Select by Weights" to_port="example set input"/>
          <connect from_op="Select by Weights" from_port="example set output" to_op="Validation" to_port="training"/>
          <connect from_op="Validation" from_port="averagable 1" to_op="Write as Text" to_port="input 1"/>
          <connect from_op="Write as Text" from_port="input 1" to_port="performance"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="source_input 2" spacing="0"/>
          <portSpacing port="sink_performance" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
        </process>
      </operator>
      <connect from_op="Generate Massive Data" from_port="output" to_op="Nominal to Binominal" to_port="example set input"/>
      <connect from_op="Nominal to Binominal" from_port="example set output" to_op="Optimize Parameters (Grid)" to_port="input 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
    </process>
  </operator>
</process>

Thanks ,
Arian 
Tagged:

Answers

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

    you can add two Set Macro operators (one for each optimized parameter) to your inner process, and iterate the values of these macros instead of directly optimizing the parameters. Then, you can use macros for both setting the actual parameters and the filename.

    Btw, you can also store the performance object in the repository with Store instead of using plain text files.

    Best, Marius
Sign In or Register to comment.