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.

[SOLVED] Logging regression coefficients

juan7710juan7710 Member Posts: 11 Contributor II
edited November 2018 in Help
Hi,

I have a loop that is running linear regressions for all iterations of a specific attribute. Each of the iterations delivers a new linear model. I am interested in extracting and logging the coefficients of each iterated regression model, but I haven't found a way to do this.

Any ideas?

Thanks!!
Tagged:

Answers

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,531 RM Data Scientist
    Have you considered to save the weights comming out of linear regression into your repository? Together with Generate Macro or %{a} you can choose different names.

    ~Martin
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • JEdwardJEdward RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 578 Unicorn
    I actually ran into similar problems as I was trying to extract the entire coefficients table (not just the weights) to use in a report. 
    I tried exporting as a formula, apparently linear regression isn't setup for formula generation yet.
    I also tried the reporting extension also, but the **** in the Code attribute stops this table exporting. 

    So the only solution I found was exporting the linear model to disk using Write Model and then using the Read XML operator to translate the model back into a data table. 
    I put this together as a very quick example, but you'll want to do it a bit neater for a robust option.  We I get time (probably in 6 months) I'll make an operator to do this. 
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="7.0.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="7.0.001" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="advanced_file_connectors:read_xml" compatibility="7.0.001" expanded="true" height="68" name="Read XML" width="90" x="112" y="34">
            <parameter key="file" value="C:\Users\user\Desktop\linearRegression.mod"/>
            <parameter key="xpath_for_examples" value="//object-stream/LinearRegressionModel/LinearRegressionModel"/>
            <enumeration key="xpaths_for_attributes">
              <parameter key="xpath_for_attribute" value="default[1]/attributeNames[1]/string[1]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/attributeNames[1]/string[2]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/attributeNames[1]/string[3]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/attributeNames[1]/string[4]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/attributeNames[1]/string[5]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/coefficients[1]/double[1]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/coefficients[1]/double[2]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/coefficients[1]/double[3]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/coefficients[1]/double[4]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/pValues[1]/double[1]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/pValues[1]/double[2]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/pValues[1]/double[3]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/pValues[1]/double[4]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/selectedAttributes[1]/boolean[1]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/selectedAttributes[1]/boolean[2]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/selectedAttributes[1]/boolean[3]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/selectedAttributes[1]/boolean[4]/text()"/>
              <parameter key="xpath_for_attribute" value="default[1]/selectedAttributes[1]/boolean[5]/text()"/>
            </enumeration>
            <list key="namespaces"/>
            <parameter key="use_default_namespace" value="false"/>
            <list key="annotations"/>
            <list key="data_set_meta_data_information">
              <parameter key="0" value="default[1]/attributeNames[1]/string[1]/text().true.attribute_value.attribute"/>
              <parameter key="1" value="default[1]/attributeNames[1]/string[2]/text().true.attribute_value.attribute"/>
              <parameter key="2" value="default[1]/attributeNames[1]/string[3]/text().true.attribute_value.attribute"/>
              <parameter key="3" value="default[1]/attributeNames[1]/string[4]/text().true.attribute_value.attribute"/>
              <parameter key="4" value="default[1]/attributeNames[1]/string[5]/text().true.attribute_value.attribute"/>
              <parameter key="5" value="default[1]/coefficients[1]/double[1]/text().true.attribute_value.attribute"/>
              <parameter key="6" value="default[1]/coefficients[1]/double[2]/text().true.attribute_value.attribute"/>
              <parameter key="7" value="default[1]/coefficients[1]/double[3]/text().true.attribute_value.attribute"/>
              <parameter key="8" value="default[1]/coefficients[1]/double[4]/text().true.attribute_value.attribute"/>
              <parameter key="9" value="default[1]/pValues[1]/double[1]/text().true.attribute_value.attribute"/>
              <parameter key="10" value="default[1]/pValues[1]/double[2]/text().true.attribute_value.attribute"/>
              <parameter key="11" value="default[1]/pValues[1]/double[3]/text().true.attribute_value.attribute"/>
              <parameter key="12" value="default[1]/pValues[1]/double[4]/text().true.attribute_value.attribute"/>
              <parameter key="13" value="default[1]/selectedAttributes[1]/boolean[1]/text().true.attribute_value.attribute"/>
              <parameter key="14" value="default[1]/selectedAttributes[1]/boolean[2]/text().true.attribute_value.attribute"/>
              <parameter key="15" value="default[1]/selectedAttributes[1]/boolean[3]/text().true.attribute_value.attribute"/>
              <parameter key="16" value="default[1]/selectedAttributes[1]/boolean[4]/text().true.attribute_value.attribute"/>
              <parameter key="17" value="default[1]/selectedAttributes[1]/boolean[5]/text().true.attribute_value.attribute"/>
            </list>
          </operator>
          <connect from_op="Read XML" from_port="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>
  • juan7710juan7710 Member Posts: 11 Contributor II
    An operator for this purpose will be great !

    Thanks
Sign In or Register to comment.