The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

tranform attribute -- help

amyargamyarg Member Posts: 2 Contributor I
Hi everybody, I recently I started using RapidMiner.  I want  to transform a nominal attribute.

old atribute      frec()  new atribute
------------                    ---------------
obrero              55        obrero
patron                30      patron
ama de casa      3        otro      ---> if frec< avg()
estudiante          2        otro
jubilado              1        otro

i not how to make them with the program, is possible to do that? thank!! HOW?

Answers

  • [Deleted User][Deleted User] Posts: 0 Newbie
    Hi amyarg,

    the process below shows one possible way to solve your problem.

    Are you familiar using macros in RapidMiner?
    The average of "frec" is assigned to this macro which makes the value accesible in the if statement of the Generate Attributes operator.

    Please make sure to rename your attributes since brackets, hyphens and whitespaces are not allowed in the function expression of this operator.
    To calculate the average of frec you have to make sure, that the value type is numerical.


    Best,
    Edin

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.008">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.008" expanded="true" name="Process">
        <process expanded="true" height="460" width="685">
          <operator activated="true" class="subprocess" compatibility="5.2.008" expanded="true" height="76" name="generate testdata" width="90" x="45" y="30">
            <process expanded="true" height="505" width="705">
              <operator activated="true" class="generate_data_user_specification" compatibility="5.2.008" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="30">
                <list key="attribute_values">
                  <parameter key="old_attribute" value="&quot;obrero&quot;"/>
                  <parameter key="frec" value="55"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="5.2.008" expanded="true" height="60" name="Generate Data by User Specification (2)" width="90" x="45" y="300">
                <list key="attribute_values">
                  <parameter key="old_attribute" value="&quot;estudiante&quot;"/>
                  <parameter key="frec" value="2"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="5.2.008" expanded="true" height="60" name="Generate Data by User Specification (3)" width="90" x="45" y="390">
                <list key="attribute_values">
                  <parameter key="old_attribute" value="&quot;jubilado&quot;"/>
                  <parameter key="frec" value="1"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="5.2.008" expanded="true" height="60" name="Generate Data by User Specification (4)" width="90" x="45" y="120">
                <list key="attribute_values">
                  <parameter key="old_attribute" value="&quot;patron&quot;"/>
                  <parameter key="frec" value="30"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="5.2.008" expanded="true" height="60" name="Generate Data by User Specification (5)" width="90" x="45" y="210">
                <list key="attribute_values">
                  <parameter key="old_attribute" value="&quot;ama de casa&quot;"/>
                  <parameter key="frec" value="3"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="append" compatibility="5.2.008" expanded="true" height="148" name="Append" width="90" x="246" y="30"/>
              <connect from_op="Generate Data by User Specification" from_port="output" to_op="Append" to_port="example set 1"/>
              <connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Append" to_port="example set 4"/>
              <connect from_op="Generate Data by User Specification (3)" from_port="output" to_op="Append" to_port="example set 5"/>
              <connect from_op="Generate Data by User Specification (4)" from_port="output" to_op="Append" to_port="example set 2"/>
              <connect from_op="Generate Data by User Specification (5)" from_port="output" to_op="Append" to_port="example set 3"/>
              <connect from_op="Append" from_port="merged set" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="subprocess" compatibility="5.2.008" expanded="true" height="76" name="calculate average" width="90" x="179" y="30">
            <process expanded="true" height="505" width="753">
              <operator activated="true" class="aggregate" compatibility="5.2.008" expanded="true" height="76" name="Aggregate" width="90" x="112" y="75">
                <list key="aggregation_attributes">
                  <parameter key="frec" value="average"/>
                </list>
              </operator>
              <operator activated="true" class="extract_macro" compatibility="5.2.008" expanded="true" height="60" name="Extract Macro" width="90" x="246" y="30">
                <parameter key="macro" value="average"/>
                <parameter key="macro_type" value="data_value"/>
                <parameter key="attribute_name" value="average(frec)"/>
                <parameter key="example_index" value="1"/>
              </operator>
              <connect from_port="in 1" to_op="Aggregate" to_port="example set input"/>
              <connect from_op="Aggregate" from_port="example set output" to_op="Extract Macro" to_port="example set"/>
              <connect from_op="Aggregate" from_port="original" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="source_in 2" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="5.2.008" expanded="true" height="76" name="Generate new attribute" width="90" x="313" y="30">
            <list key="function_descriptions">
              <parameter key="new_attribute" value="if(frec&lt;%{average},&quot;otro&quot;,old_attribute)"/>
            </list>
          </operator>
          <connect from_op="generate testdata" from_port="out 1" to_op="calculate average" to_port="in 1"/>
          <connect from_op="calculate average" from_port="out 1" to_op="Generate new attribute" to_port="example set input"/>
          <connect from_op="Generate new attribute" 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>
Sign In or Register to comment.