首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >快速矿排最大值

快速矿排最大值
EN

Stack Overflow用户
提问于 2017-05-15 19:20:18
回答 3查看 453关注 0票数 1

对不起,我对RapidMiner完全陌生,只做了基础教程。

我有一个数据集

代码语言:javascript
运行
复制
MatchID   Value1   Value2   Value3
1            5        1        2
1           4.5      1.5       2
...

并且想知道是否有可能获得每个列的最高值(例如Value1),并使用它进行进一步的计算(生成属性)。

谢谢。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-05-15 19:45:42

事情发生时有很多种方式。这里有一个使用Aggregate操作符来查找maxima,Join将这个加入到原始,Generate Attributes来做一些计算。

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?><process version="7.2.003">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="7.2.003" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="retrieve" compatibility="7.2.003" expanded="true" height="68" name="Retrieve Iris" width="90" x="45" y="34">
    <parameter key="repository_entry" value="//Samples/data/Iris"/>
      </operator>
      <operator activated="true" class="aggregate" compatibility="7.2.003" expanded="true" height="82" name="Aggregate" width="90" x="179" y="34">
    <parameter key="use_default_aggregation" value="true"/>
    <parameter key="default_aggregation_function" value="maximum"/>
    <list key="aggregation_attributes"/>
      </operator>
      <operator activated="true" class="join" compatibility="7.2.003" expanded="true" height="82" name="Join" width="90" x="313" y="34">
    <parameter key="join_type" value="outer"/>
    <parameter key="use_id_attribute_as_key" value="false"/>
    <list key="key_attributes"/>
      </operator>
      <operator activated="true" class="generate_attributes" compatibility="7.2.003" expanded="true" height="82" name="Generate Attributes" width="90" x="447" y="34">
    <list key="function_descriptions">
      <parameter key="deltaA1" value="[maximum(a1)]-a1"/>
      <parameter key="deltaA2" value="[maximum(a2)]-a2"/>
      <parameter key="deltaA3" value="[maximum(a3)]-a3"/>
      <parameter key="deltaA4" value="[maximum(a4)]-a4"/>
    </list>
      </operator>
      <connect from_op="Retrieve Iris" from_port="output" to_op="Aggregate" to_port="example set input"/>
      <connect from_op="Aggregate" from_port="example set output" to_op="Join" to_port="left"/>
      <connect from_op="Aggregate" from_port="original" to_op="Join" to_port="right"/>
      <connect from_op="Join" from_port="join" 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"/>
    </process>
  </operator>
</process>
票数 3
EN

Stack Overflow用户

发布于 2017-05-17 10:00:41

另一种方法是使用Extract Macro运算符和statistics设置max。这会将给定属性的最大值存储为宏值,然后可以使用该值,例如在Generate Attributes中。

优点是不需要修改原始数据集,也不必使用joinmultiply运算符。

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?><process version="7.5.000">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="7.5.000" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="retrieve" compatibility="7.5.000" expanded="true" height="68" name="Retrieve Iris" width="90" x="45" y="34">
        <parameter key="repository_entry" value="//Samples/data/Iris"/>
      </operator>
      <operator activated="true" class="extract_macro" compatibility="7.5.000" expanded="true" height="68" name="Extract Macro" width="90" x="179" y="34">
        <parameter key="macro" value="maxA1"/>
        <parameter key="macro_type" value="statistics"/>
        <parameter key="statistics" value="max"/>
        <parameter key="attribute_name" value="a1"/>
        <list key="additional_macros"/>
        <description align="center" color="transparent" colored="false" width="126">extract maximum of attribute a1 and store it in a macro</description>
      </operator>
      <operator activated="true" class="generate_attributes" compatibility="7.5.000" expanded="true" height="82" name="Generate Attributes" width="90" x="313" y="34">
        <list key="function_descriptions">
          <parameter key="DifferenceA1" value="parse(%{maxA1})-a1"/>
        </list>
        <description align="center" color="transparent" colored="false" width="126">calculate the difference of a1 from the maximum using the macro value</description>
      </operator>
      <connect from_op="Retrieve Iris" from_port="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"/>
    </process>
  </operator>
</process>

提示:由于宏值是以文本形式存储的,因此必须首先对它们进行parse,才能使用它们的数值。

票数 0
EN

Stack Overflow用户

发布于 2017-05-17 10:07:34

第三个选项是Sort示例集,并且只使用Filter Example Range操作符保留该示例的最大值。如果您对其他属性值很感兴趣,那么当某个属性是最大的时,这是有用的。

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?><process version="7.5.000">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="7.5.000" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="retrieve" compatibility="7.5.000" expanded="true" height="68" name="Retrieve Iris" width="90" x="45" y="34">
        <parameter key="repository_entry" value="//Samples/data/Iris"/>
      </operator>
      <operator activated="true" class="sort" compatibility="7.5.000" expanded="true" height="82" name="Sort" width="90" x="179" y="34">
        <parameter key="attribute_name" value="a1"/>
        <parameter key="sorting_direction" value="decreasing"/>
        <description align="center" color="transparent" colored="false" width="126">sorting the example set on a1 decreasing</description>
      </operator>
      <operator activated="true" class="filter_example_range" compatibility="7.5.000" expanded="true" height="82" name="Filter Example Range" width="90" x="313" y="34">
        <parameter key="first_example" value="1"/>
        <parameter key="last_example" value="1"/>
        <description align="center" color="transparent" colored="false" width="126">only keeping the first example, which has the maximum for a1</description>
      </operator>
      <connect from_op="Retrieve Iris" from_port="output" to_op="Sort" to_port="example set input"/>
      <connect from_op="Sort" from_port="example set output" to_op="Filter Example Range" to_port="example set input"/>
      <connect from_op="Filter Example Range" 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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43987256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档