Options

Loop attributes with generate aggregation for series processing bugging.

mafern76mafern76 Member Posts: 45 Contributor II
edited November 2018 in Help
I have the following attributes:

att0_ts
att0_ts_2
att0_ts_3
att0_ts_4
att1_ts
... and so on, the idea is to work on an arbitrary amount of attribute time stamp blocks, ts stands for time stamp, having 4 ordered time measures for each attribute.

I want to calculate the difference and ratio between each ts, then aggregating horizontally sum, avg, min and max to get a sense of series progression.

I programmed it but I'm getting weird bugs, at first it worked, then it didn't, then it only calculates the first generate... I can't seem to reproduce an exact problem or reason. I don't know if it has anything to do with it, but first I tried selecting attributes for generate using %{loop_attribute}, and I noticed after running it it changes to looop_attribute.

You can copy paste this into excel to get the sample table:

id att0_ts att0_ts_1 att0_ts_2 att0_ts_3
1 5 4 3 2
2 3 4 5 6

Below the loop:

Thanks in advance!
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.015">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="loop_attributes" compatibility="5.3.015" expanded="true" height="76" name="horizontal" width="90" x="380" y="300">
    <parameter key="attribute_filter_type" value="regular_expression"/>
    <parameter key="attribute" value=""/>
    <parameter key="attributes" value="|att1|att0"/>
    <parameter key="regular_expression" value=".*_ts"/>
    <parameter key="use_except_expression" value="false"/>
    <parameter key="value_type" value="attribute_value"/>
    <parameter key="use_value_type_exception" value="false"/>
    <parameter key="except_value_type" value="time"/>
    <parameter key="block_type" value="attribute_block"/>
    <parameter key="use_block_type_exception" value="false"/>
    <parameter key="except_block_type" value="value_matrix_row_start"/>
    <parameter key="invert_selection" value="false"/>
    <parameter key="include_special_attributes" value="false"/>
    <parameter key="iteration_macro" value="loop_attribute"/>
    <parameter key="parallelize_subprocess" value="false"/>
    <process expanded="true">
      <operator activated="true" class="generate_attributes" compatibility="5.3.015" expanded="true" height="76" name="Generate Attributes" width="90" x="45" y="30">
        <list key="function_descriptions">
          <parameter key="dif1_%{loop_attribute}" value="%{loop_attribute} - %{loop_attribute}_2"/>
          <parameter key="dif2_%{loop_attribute}" value="%{loop_attribute}_2 - %{loop_attribute}_3"/>
          <parameter key="dif3_%{loop_attribute}" value="%{loop_attribute}_3 - %{loop_attribute}_4"/>
        </list>
        <parameter key="use_standard_constants" value="true"/>
        <parameter key="keep_all" value="true"/>
      </operator>
      <operator activated="true" class="generate_aggregation" compatibility="5.3.015" expanded="true" height="76" name="Generate Aggregation (3)" width="90" x="246" y="30">
        <parameter key="attribute_name" value="sum_dif"/>
        <parameter key="attribute_filter_type" value="subset"/>
        <parameter key="attribute" value=""/>
        <parameter key="attributes" value="dif1_loop_attribute|dif2_loop_attribute|dif3_loop_attribute"/>
        <parameter key="use_except_expression" value="false"/>
        <parameter key="value_type" value="attribute_value"/>
        <parameter key="use_value_type_exception" value="false"/>
        <parameter key="except_value_type" value="time"/>
        <parameter key="block_type" value="attribute_block"/>
        <parameter key="use_block_type_exception" value="false"/>
        <parameter key="except_block_type" value="value_matrix_row_start"/>
        <parameter key="invert_selection" value="false"/>
        <parameter key="include_special_attributes" value="false"/>
        <parameter key="aggregation_function" value="sum"/>
        <parameter key="keep_all" value="true"/>
        <parameter key="ignore_missings" value="true"/>
      </operator>
      <operator activated="true" class="generate_aggregation" compatibility="5.3.015" expanded="true" height="76" name="Generate Aggregation (2)" width="90" x="380" y="30">
        <parameter key="attribute_name" value="avg_dif"/>
        <parameter key="attribute_filter_type" value="subset"/>
        <parameter key="attribute" value=""/>
        <parameter key="attributes" value="dif1_loop_attribute|dif2_loop_attribute|dif3_loop_attribute|"/>
        <parameter key="use_except_expression" value="false"/>
        <parameter key="value_type" value="attribute_value"/>
        <parameter key="use_value_type_exception" value="false"/>
        <parameter key="except_value_type" value="time"/>
        <parameter key="block_type" value="attribute_block"/>
        <parameter key="use_block_type_exception" value="false"/>
        <parameter key="except_block_type" value="value_matrix_row_start"/>
        <parameter key="invert_selection" value="false"/>
        <parameter key="include_special_attributes" value="false"/>
        <parameter key="aggregation_function" value="average"/>
        <parameter key="keep_all" value="true"/>
        <parameter key="ignore_missings" value="true"/>
      </operator>
      <operator activated="true" class="generate_aggregation" compatibility="5.3.015" expanded="true" height="76" name="Generate Aggregation (4)" width="90" x="514" y="30">
        <parameter key="attribute_name" value="min_dif"/>
        <parameter key="attribute_filter_type" value="subset"/>
        <parameter key="attribute" value=""/>
        <parameter key="attributes" value="dif1_loop_attribute|dif2_loop_attribute|dif3_loop_attribute|"/>
        <parameter key="use_except_expression" value="false"/>
        <parameter key="value_type" value="attribute_value"/>
        <parameter key="use_value_type_exception" value="false"/>
        <parameter key="except_value_type" value="time"/>
        <parameter key="block_type" value="attribute_block"/>
        <parameter key="use_block_type_exception" value="false"/>
        <parameter key="except_block_type" value="value_matrix_row_start"/>
        <parameter key="invert_selection" value="false"/>
        <parameter key="include_special_attributes" value="false"/>
        <parameter key="aggregation_function" value="minimum"/>
        <parameter key="keep_all" value="true"/>
        <parameter key="ignore_missings" value="true"/>
      </operator>
      <operator activated="true" class="generate_aggregation" compatibility="5.3.015" expanded="true" height="76" name="Generate Aggregation (13)" width="90" x="715" y="30">
        <parameter key="attribute_name" value="max_dif"/>
        <parameter key="attribute_filter_type" value="subset"/>
        <parameter key="attribute" value=""/>
        <parameter key="attributes" value="dif1_loop_attribute|dif2_loop_attribute|dif3_loop_attribute|"/>
        <parameter key="use_except_expression" value="false"/>
        <parameter key="value_type" value="attribute_value"/>
        <parameter key="use_value_type_exception" value="false"/>
        <parameter key="except_value_type" value="time"/>
        <parameter key="block_type" value="attribute_block"/>
        <parameter key="use_block_type_exception" value="false"/>
        <parameter key="except_block_type" value="value_matrix_row_start"/>
        <parameter key="invert_selection" value="false"/>
        <parameter key="include_special_attributes" value="false"/>
        <parameter key="aggregation_function" value="maximum"/>
        <parameter key="keep_all" value="true"/>
        <parameter key="ignore_missings" value="true"/>
      </operator>
      <connect from_port="example set" to_op="Generate Attributes" to_port="example set input"/>
      <connect from_op="Generate Attributes" from_port="example set output" to_op="Generate Aggregation (3)" to_port="example set input"/>
      <connect from_op="Generate Aggregation (3)" from_port="example set output" to_op="Generate Aggregation (2)" to_port="example set input"/>
      <connect from_op="Generate Aggregation (2)" from_port="example set output" to_op="Generate Aggregation (4)" to_port="example set input"/>
      <connect from_op="Generate Aggregation (4)" from_port="example set output" to_op="Generate Aggregation (13)" to_port="example set input"/>
      <connect from_op="Generate Aggregation (13)" 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>
</process>
Sign In or Register to comment.