0

I want to generate a new attribute where the attribute name(s) that has highest value is stored. My goal is similar like this question (Returning the column header of max value on per row basis).

Community
  • 1
  • 1
Irteza
  • 1
  • 1

1 Answers1

0

It's quite complicated and involves transposing each example within an example set, sorting to find the maximum, extracting the name of the attribute into a macro and setting this value into the original example set.

Here's a process that you can copy.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.5.000">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="6.5.000" expanded="true" name="Process">
    <parameter key="logverbosity" value="init"/>
    <parameter key="random_seed" value="2001"/>
    <parameter key="send_mail" value="never"/>
    <parameter key="notification_email" value=""/>
    <parameter key="process_duration_for_mail" value="30"/>
    <parameter key="encoding" value="SYSTEM"/>
    <parameter key="parallelize_main_process" value="false"/>
    <process expanded="true">
      <operator activated="true" class="generate_data" compatibility="6.5.000" expanded="true" height="60" name="Generate Data" width="90" x="112" y="75">
        <parameter key="target_function" value="random"/>
        <parameter key="number_examples" value="100"/>
        <parameter key="number_of_attributes" value="5"/>
        <parameter key="attributes_lower_bound" value="-10.0"/>
        <parameter key="attributes_upper_bound" value="10.0"/>
        <parameter key="use_local_random_seed" value="false"/>
        <parameter key="local_random_seed" value="1992"/>
        <parameter key="datamanagement" value="double_array"/>
      </operator>
      <operator activated="true" class="generate_attributes" compatibility="6.5.000" expanded="true" height="76" name="Generate Attributes" width="90" x="246" y="75">
        <list key="function_descriptions">
          <parameter key="maximum" value="&quot;unknown&quot;"/>
        </list>
        <parameter key="keep_all" value="true"/>
      </operator>
      <operator activated="true" class="loop_examples" compatibility="6.5.000" expanded="true" height="76" name="Loop Examples" width="90" x="380" y="75">
        <parameter key="iteration_macro" value="example"/>
        <parameter key="parallelize_example_process" value="false"/>
        <process expanded="true">
          <operator activated="true" class="filter_example_range" compatibility="6.5.000" expanded="true" height="76" name="Filter Example Range" width="90" x="112" y="30">
            <parameter key="first_example" value="%{example}"/>
            <parameter key="last_example" value="%{example}"/>
            <parameter key="invert_filter" value="false"/>
          </operator>
          <operator activated="true" class="select_attributes" compatibility="6.5.000" expanded="true" height="76" name="Select Attributes" width="90" x="112" y="165">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attribute" value=""/>
            <parameter key="attributes" value="id|label|maximum"/>
            <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="true"/>
            <parameter key="include_special_attributes" value="true"/>
          </operator>
          <operator activated="true" class="transpose" compatibility="6.5.000" expanded="true" height="76" name="Transpose" width="90" x="246" y="165"/>
          <operator activated="true" class="sort" compatibility="6.5.000" expanded="true" height="76" name="Sort" width="90" x="380" y="165">
            <parameter key="attribute_name" value="att_1"/>
            <parameter key="sorting_direction" value="decreasing"/>
          </operator>
          <operator activated="true" class="extract_macro" compatibility="6.5.000" expanded="true" height="60" name="Extract Macro" width="90" x="514" y="165">
            <parameter key="macro" value="max"/>
            <parameter key="macro_type" value="data_value"/>
            <parameter key="statistics" value="average"/>
            <parameter key="attribute_name" value="id"/>
            <parameter key="example_index" value="1"/>
            <list key="additional_macros"/>
          </operator>
          <operator activated="true" class="subprocess" compatibility="6.5.000" expanded="true" height="94" name="Subprocess" width="90" x="648" y="30">
            <parameter key="parallelize_nested_process" value="false"/>
            <process expanded="true">
              <connect from_port="in 1" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="source_in 2" spacing="0"/>
              <portSpacing port="source_in 3" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="set_data" compatibility="6.5.000" expanded="true" height="76" name="Set Data" width="90" x="782" y="30">
            <parameter key="example_index" value="%{example}"/>
            <parameter key="count_backwards" value="false"/>
            <parameter key="attribute_name" value="maximum"/>
            <parameter key="value" value="%{max}"/>
            <list key="additional_values"/>
          </operator>
          <connect from_port="example set" to_op="Filter Example Range" to_port="example set input"/>
          <connect from_op="Filter Example Range" from_port="example set output" to_op="Select Attributes" to_port="example set input"/>
          <connect from_op="Filter Example Range" from_port="original" to_op="Subprocess" to_port="in 1"/>
          <connect from_op="Select Attributes" from_port="example set output" to_op="Transpose" to_port="example set input"/>
          <connect from_op="Transpose" from_port="example set output" to_op="Sort" to_port="example set input"/>
          <connect from_op="Sort" from_port="example set output" to_op="Extract Macro" to_port="example set"/>
          <connect from_op="Extract Macro" from_port="example set" to_op="Subprocess" to_port="in 2"/>
          <connect from_op="Subprocess" from_port="out 1" to_op="Set Data" to_port="example set input"/>
          <connect from_op="Set Data" 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_output 1" spacing="0"/>
        </process>
      </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_op="Loop Examples" to_port="example set"/>
      <connect from_op="Loop Examples" from_port="example set" 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>
Andrew Chisholm
  • 6,362
  • 2
  • 22
  • 41