The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Convert model output to example set

mikeyharmsmikeyharms Member Posts: 13 Contributor II
edited November 2018 in Help
I am trying to convert the coefficients table from a linear regression in to an example set. Any ideas? I have begun using the Execute Script operator but I can't get it bring back exactly what I need.

Cheers,

Mike

Answers

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist
    The linear regression is returning the coefficents as a weight table as well.
    You can simply use this in combination with Weights to Data.

    Here is an example process based on sonar data

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.1.001-SNAPSHOT">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.1.001-SNAPSHOT" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="retrieve" compatibility="6.1.001-SNAPSHOT" expanded="true" height="60" name="Retrieve Sonar" width="90" x="179" y="120">
            <parameter key="repository_entry" value="//Samples/data/Sonar"/>
          </operator>
          <operator activated="true" class="linear_regression" compatibility="6.1.001-SNAPSHOT" expanded="true" height="94" name="Linear Regression" width="90" x="380" y="120"/>
          <operator activated="true" class="weights_to_data" compatibility="6.1.001-SNAPSHOT" expanded="true" height="60" name="Weights to Data" width="90" x="514" y="165"/>
          <connect from_op="Retrieve Sonar" from_port="output" to_op="Linear Regression" to_port="training set"/>
          <connect from_op="Linear Regression" from_port="weights" to_op="Weights to Data" to_port="attribute weights"/>
          <connect from_op="Weights to Data" from_port="example set" 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>

    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • mikeyharmsmikeyharms Member Posts: 13 Contributor II
    Cheers for the reply. I'm a bit embarrassed I didn't think of this though it doesn't bring back the Intercept coefficient.

    I have written some script that brings back the elements I need but if there is a method that avoids script then I'm open to ideas!

    Mike
  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist
    In case of an regression problem you can apply the model onto a dataset with all attributes=0. In this case the prediction is the intercept.

    Example process:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.1.001-SNAPSHOT">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.1.001-SNAPSHOT" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data" compatibility="6.1.001-SNAPSHOT" expanded="true" height="60" name="Generate Data" width="90" x="45" y="210"/>
          <operator activated="true" class="multiply" compatibility="6.1.001-SNAPSHOT" expanded="true" height="94" name="Multiply" width="90" x="246" y="165"/>
          <operator activated="true" class="loop_attributes" compatibility="6.1.001-SNAPSHOT" expanded="true" height="76" name="Loop Attributes" width="90" x="380" y="345">
            <process expanded="true">
              <operator activated="true" class="set_data" compatibility="6.1.001-SNAPSHOT" expanded="true" height="76" name="Set Data" width="90" x="179" y="120">
                <parameter key="example_index" value="1"/>
                <parameter key="attribute_name" value="%{loop_attribute}"/>
                <parameter key="value" value="0"/>
                <list key="additional_values"/>
              </operator>
              <connect from_port="example set" to_op="Set Data" to_port="example set input"/>
              <connect from_op="Set Data" from_port="example set output" to_port="example set"/>
              <portSpacing port="source_example set" spacing="0"/>
              <portSpacing port="sink_example set" spacing="0"/>
              <portSpacing port="sink_result 1" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="filter_examples" compatibility="6.1.001-SNAPSHOT" expanded="true" height="94" name="Filter Examples" width="90" x="514" y="345">
            <list key="filters_list">
              <parameter key="filters_entry_key" value="att1.eq.0"/>
            </list>
          </operator>
          <operator activated="true" class="linear_regression" compatibility="6.1.001-SNAPSHOT" expanded="true" height="94" name="Linear Regression" width="90" x="447" y="120"/>
          <operator activated="true" class="apply_model" compatibility="6.1.001-SNAPSHOT" expanded="true" height="76" name="Apply Model" width="90" x="581" y="210">
            <list key="application_parameters"/>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Multiply" to_port="input"/>
          <connect from_op="Multiply" from_port="output 1" to_op="Linear Regression" to_port="training set"/>
          <connect from_op="Multiply" from_port="output 2" to_op="Loop Attributes" to_port="example set"/>
          <connect from_op="Loop Attributes" from_port="example set" to_op="Filter Examples" to_port="example set input"/>
          <connect from_op="Filter Examples" from_port="example set output" to_op="Apply Model" to_port="unlabelled data"/>
          <connect from_op="Linear Regression" from_port="model" to_op="Apply Model" to_port="model"/>
          <connect from_op="Apply Model" from_port="labelled data" to_port="result 1"/>
          <connect from_op="Apply Model" from_port="model" to_port="result 2"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="180"/>
          <portSpacing port="sink_result 2" spacing="18"/>
          <portSpacing port="sink_result 3" spacing="0"/>
        </process>
      </operator>
    </process>


    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • mikeyharmsmikeyharms Member Posts: 13 Contributor II
    Great idea, thanks.

    Mike
Sign In or Register to comment.