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.

Cumulative average

vinothrajanvinothrajan Member Posts: 3 Contributor I
edited November 2018 in Help
Hi ..
Need to calculate cumulative average,able to do cumulative sum. But want to calculate cumulative average like below

C1 C2 C3
1    1    1
2    3    1.5
3    6    2

here C1 - real value,c2 cumulative sum,c3 cumulative average-which need to calculate.

thanks in advance. :)

Answers

  • qwertzqwertz Member Posts: 130 Contributor II

    Hi,

    so if I get you right, you have already C1 and C2 as an example set. In this case you can simply use "generate attributes" to calculate C3.
    In case you don't have C2 you can use loop operator to generate is as well.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.0.008">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.0.008" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data" compatibility="6.0.008" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">
            <parameter key="number_examples" value="10"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="6.0.008" expanded="true" height="76" name="Generate Attributes" width="90" x="179" y="30">
            <list key="function_descriptions">
              <parameter key="C3" value="att2/att1"/>
            </list>
          </operator>
          <connect from_op="Generate Data" from_port="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>

    Cheers
    Sachs
  • vinothrajanvinothrajan Member Posts: 3 Contributor I
    thanks for your reply, but in code you mentioned like c3=c2/c1. Let me explain my example more clear. Need to calculate cumulative average for below values.

    input:
    ?
    ?
    77841
    11992369
    782045.444
    4690112.111
    176680.111
    --------------------------

    output:

    ?
    ?
    77841
    6035105 <== ((77841+11992369)/2)
    4284085.148 <== ((77841+11992369+782045.444)/3)
    4385591.88875 <== ((77841+11992369+782045.444+4690112.111)/4)
    176680.111
  • qwertzqwertz Member Posts: 130 Contributor II
    Ok, got your point. Have a look to this post here: http://rapid-i.com/rapidforum/index.php/topic,5413.0.html
    It shows how to loop (iterate) through an attribute (column) and write the difference of two proximate data values to a new attribute.
    As this is quite similar to your question and provides all the tools (macros, loop, etc.) you need I hope that you can easily adapt it.
    In case you still have troubles go as far as you can get and post your code here.

    Cheers
    Sachs
Sign In or Register to comment.