Generate Attribute depending on 2 values in previous rows

User: "MPB_"
New Altair Community Member
Updated by Jocelyn
Hi there,

I already searched the forum but did not find anything very helpful.

Let´s say I have some easy sales-data in an example-set like this:

Week | Product | UnitPrice | Unit_Sales
01_19| Beer_A | 0.99          | 10
02_19| Beer_A | 0.85          | 20



I would like to generate a new Attribute which:

  •  either gives the price of a product of the last week
  • or already calulates the price-difference from the previous week to the actual row/week

Is that even possible with the operator  Generate Attribute?


Best regards and have a nice day :)



Find more posts tagged with

Sort by:
1 - 4 of 41
    Hi,
    you most likely want to use first the Lag operator and combine this with Generate Attributes.

    Cheers,
    Martin
    User: "MPB_"
    New Altair Community Member
    OP
    Hi Martin, thank you for your answer.

    Could you please explain that? How exactly would you lag this and how would you combine that with generate Attributes?
    User: "MartinLiebig"
    Altair Employee
    Accepted Answer

    please have a look at the attached process. That should explain it.

    BR,

    Martin

    <?xml version="1.0" encoding="UTF-8"?><process version="9.4.001"><br>  <context><br>    <input/><br>    <output/><br>    <macros/><br>  </context><br>  <operator activated="true" class="process" compatibility="9.4.001" expanded="true" name="Process"><br>    <parameter key="logverbosity" value="init"/><br>    <parameter key="random_seed" value="2001"/><br>    <parameter key="send_mail" value="never"/><br>    <parameter key="notification_email" value=""/><br>    <parameter key="process_duration_for_mail" value="30"/><br>    <parameter key="encoding" value="SYSTEM"/><br>    <process expanded="true"><br>      <operator activated="true" class="utility:create_exampleset" compatibility="9.4.001" expanded="true" height="68" name="Create ExampleSet" width="90" x="179" y="85"><br>        <parameter key="generator_type" value="comma separated text"/><br>        <parameter key="number_of_examples" value="100"/><br>        <parameter key="use_stepsize" value="false"/><br>        <list key="function_descriptions"/><br>        <parameter key="add_id_attribute" value="false"/><br>        <list key="numeric_series_configuration"/><br>        <list key="date_series_configuration"/><br>        <list key="date_series_configuration (interval)"/><br>        <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/><br>        <parameter key="time_zone" value="SYSTEM"/><br>        <parameter key="input_csv_text" value="Week | Product | UnitPrice | Unit_Sales&#10;01_19| Beer_A | 0.99          | 10&#10;02_19| Beer_A | 0.85          | 20"/><br>        <parameter key="column_separator" value="\|"/><br>        <parameter key="parse_all_as_nominal" value="false"/><br>        <parameter key="decimal_point_character" value="."/><br>        <parameter key="trim_attribute_names" value="true"/><br>      </operator><br>      <operator activated="true" class="time_series:lag_series" compatibility="9.4.001" expanded="true" height="82" name="Lag" width="90" x="380" y="85"><br>        <list key="attributes"><br>          <parameter key="UnitPrice" value="1"/><br>        </list><br>        <parameter key="overwrite_attributes" value="false"/><br>        <parameter key="extend_exampleset" value="false"/><br>      </operator><br>      <operator activated="true" class="generate_attributes" compatibility="9.4.001" expanded="true" height="82" name="Generate Attributes" width="90" x="581" y="85"><br>        <list key="function_descriptions"><br>          <parameter key="DeltaPrice" value="[UnitPrice-1]-UnitPrice"/><br>        </list><br>        <parameter key="keep_all" value="true"/><br>      </operator><br>      <connect from_op="Create ExampleSet" from_port="output" to_op="Lag" to_port="example set input"/><br>      <connect from_op="Lag" from_port="example set output" to_op="Generate Attributes" to_port="example set input"/><br>      <connect from_op="Generate Attributes" from_port="example set output" to_port="result 1"/><br>      <portSpacing port="source_input 1" spacing="0"/><br>      <portSpacing port="sink_result 1" spacing="0"/><br>      <portSpacing port="sink_result 2" spacing="0"/><br>    </process><br>  </operator><br></process><br><br>



    User: "MPB_"
    New Altair Community Member
    OP
    Thank you very much Sir!!!!