[SOLVED] how to generate constant attribute that is function of example set

tennenrishintennenrishin Member Posts: 177 Contributor II
edited November 2018 in Help
Is there a way to generate a constant attribute that is, for example, the median of some other attribute in the entire example set? For example, with input example set
generate median attribute to obtain
1, 3
2, 3
3, 3
4, 3
5, 3



  • Options
    awchisholmawchisholm RapidMiner Certified Expert, Member Posts: 458 Unicorn

    Here's an example

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.011">
      <operator activated="true" class="process" compatibility="5.1.011" expanded="true" name="Process">
        <process expanded="true" height="386" width="748">
          <operator activated="true" class="generate_data" compatibility="5.1.011" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30"/>
          <operator activated="true" class="generate_id" compatibility="5.1.011" expanded="true" height="76" name="Generate ID" width="90" x="45" y="120"/>
          <operator activated="true" class="set_role" compatibility="5.1.011" expanded="true" height="76" name="Set Role" width="90" x="45" y="210">
            <parameter key="name" value="id"/>
            <list key="set_additional_roles"/>
          <operator activated="true" class="select_attributes" compatibility="5.1.011" expanded="true" height="76" name="Select Attributes" width="90" x="45" y="300">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attributes" value="|id"/>
            <parameter key="include_special_attributes" value="true"/>
          <operator activated="true" class="extract_macro" compatibility="5.1.011" expanded="true" height="60" name="Extract Macro" width="90" x="179" y="30">
            <parameter key="macro" value="mean"/>
            <parameter key="macro_type" value="statistics"/>
            <parameter key="attribute_name" value="id"/>
          <operator activated="true" class="generate_attributes" compatibility="5.1.011" expanded="true" height="76" name="Generate Attributes" width="90" x="179" y="120">
            <list key="function_descriptions">
              <parameter key="difference" value="id-%{mean}"/>
          <connect from_op="Generate Data" from_port="output" to_op="Generate ID" to_port="example set input"/>
          <connect from_op="Generate ID" from_port="example set output" to_op="Set Role" to_port="example set input"/>
          <connect from_op="Set Role" from_port="example set output" to_op="Select Attributes" to_port="example set input"/>
          <connect from_op="Select Attributes" from_port="example set output" to_op="Extract Macro" to_port="example set"/>
          <connect from_op="Extract Macro" from_port="example set" 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"/>


  • Options
    tennenrishintennenrishin Member Posts: 177 Contributor II
    Thank you Andrew!

    Summary: use Extract Macro operator, and generate new attribute using extracted macro.
Sign In or Register to comment.