Options

"Gamma Linear Regression - Do RapidMiner support this function?"

archiquearchique Member Posts: 1 Contributor I
edited June 2019 in Help
Hi All,

I want to perform cross validation of linear regression, but in my case, my data do not support linear regression. I need to use Gamma Log Linear Regression. Could you please suggest which modelling function should I use? I have tried Linear Regression but when I compare the results using SPSS, it shows a big different.


Thanks,
Shahida
Tagged:

Answers

  • Options
    earmijoearmijo Member Posts: 270 Unicorn
    That I know there is no such operator in Rapidminer.

    What would I do? I would do it in R. I'm thinking of

    glm(count ~ x1+x2+x3, data=mydata, family=poisson())

    If you still want to do a lot of computations in RapidMiner I would use "Execute R Script".

    Here's a process (the dataset warpbreaks comes with R)
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.5.002">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.5.002" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" breakpoints="after" class="retrieve" compatibility="6.5.002" expanded="true" height="60" name="Read Warpbreaks" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Clases/data/warpbreaks"/>
            <description align="center" color="blue" colored="true" width="126">Read Warpbreaks Dataset</description>
          </operator>
          <operator activated="true" class="split_data" compatibility="6.5.002" expanded="true" height="94" name="Split Data" width="90" x="246" y="30">
            <enumeration key="partitions">
              <parameter key="ratio" value="0.75"/>
              <parameter key="ratio" value="0.25"/>
            </enumeration>
            <description align="center" color="purple" colored="true" width="126">Split the data in a training and a test set</description>
          </operator>
          <operator activated="true" class="r_scripting:execute_r" compatibility="6.5.000" expanded="true" height="76" name="Learn Model" width="90" x="514" y="30">
            <parameter key="script" value="# train a Poisson model on the training data and return the learned model&#10;&#10;rm_main = function(data)&#10;{&#10;&#9;PoissonModel &lt;- lm(formula =breaks ~ . ,  data =data,family=poisson())&#10;    &#9;return(PoissonModel)&#10;}&#10;"/>
            <description align="center" color="red" colored="true" width="126">Train a Poisson model in R and return it as an R object</description>
          </operator>
          <operator activated="true" class="r_scripting:execute_r" compatibility="6.5.000" expanded="true" height="94" name="Apply R Model" width="90" x="648" y="210">
            <parameter key="script" value="## load the trained model and apply it on the test data&#10;&#10;rm_main = function(model, data)&#10;{&#10;  &#10;  # apply the model and build a prediction&#10;  result &lt;-predict(model, data)&#10;&#10;  # add the prediction to the example set&#10;  data$prediction &lt;- result&#10;  &#10;  # update the meta data&#10;  metaData$data$prediction &lt;&lt;- list(type=&quot;real&quot;, role=&quot;prediction&quot;)&#10;  &#10;  return(data)&#10;}&#10;"/>
            <description align="center" color="red" colored="true" width="126">Apply the trained model on the test data</description>
          </operator>
          <connect from_op="Read Warpbreaks" from_port="output" to_op="Split Data" to_port="example set"/>
          <connect from_op="Split Data" from_port="partition 1" to_op="Learn Model" to_port="input 1"/>
          <connect from_op="Split Data" from_port="partition 2" to_op="Apply R Model" to_port="input 2"/>
          <connect from_op="Learn Model" from_port="output 1" to_op="Apply R Model" to_port="input 1"/>
          <connect from_op="Apply R Model" 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"/>
        </process>
      </operator>
    </process>
Sign In or Register to comment.