我刚刚开始使用RapidMiner,我正在寻找一种方法来迭代遍历一个属性,提取特定的整数值,并为每次迭代触发基于整数值创建新插入。
我认为可以使用循环值任务。在子流程中,我将使用迭代的特定值,然后触发新数据集的生成。但循环值似乎只与名义值一起使用。
此外,如何通过使用属性的当前值来定义迭代次数(例如,对于函数Loop)?
有什么想法吗?
UPDATE1:
循环示例似乎是第一步的正确选择,因为循环值会检查特定属性的不同值的存在量。
UPDATE2:
带循环的部分:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.013">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.3.013" expanded="true" name="Process">
<parameter key="resultfile" value="/home/test.res"/>
<process expanded="true">
<operator activated="true" breakpoints="after" class="read_excel" compatibility="5.3.013" expanded="true" height="60" name="Read Excel" width="90" x="1586" y="615">
<parameter key="excel_file" value="D:\stack.xlsx"/>
<list key="annotations"/>
<list key="data_set_meta_data_information"/>
</operator>
<operator activated="true" breakpoints="after" class="loop_examples" compatibility="5.3.013" expanded="true" height="76" name="Loop Examples" width="90" x="1921" y="615">
<process expanded="true">
<operator activated="true" breakpoints="after" class="extract_macro" compatibility="5.3.013" expanded="true" height="60" name="Extract Macro" width="90" x="112" y="30">
<parameter key="macro" value="macro_value"/>
<parameter key="macro_type" value="data_value"/>
<parameter key="attribute_name" value="att9"/>
<parameter key="example_index" value="1"/>
<list key="additional_macros"/>
</operator>
<operator activated="true" breakpoints="after" class="loop" compatibility="5.3.013" expanded="true" height="76" name="Loop (2)" width="90" x="380" y="30">
<parameter key="set_iteration_macro" value="true"/>
<parameter key="iterations" value="%{macro_value}"/>
<process expanded="true">
<operator activated="true" breakpoints="after" class="generate_data_user_specification" compatibility="5.3.013" expanded="true" height="60" name="Generate Data by User Specification (2)" width="90" x="45" y="300">
<list key="attribute_values">
<parameter key="person_type_id" value="3"/>
</list>
<list key="set_additional_roles"/>
</operator>
<operator activated="true" breakpoints="after" class="select_attributes" compatibility="5.3.013" expanded="true" height="76" name="Select Attributes (8)" width="90" x="112" y="120">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attributes" value="id|temp_id||att9"/>
</operator>
<operator activated="true" breakpoints="after" class="join" compatibility="5.3.013" expanded="true" height="76" name="Join (5)" width="90" x="246" y="255">
<parameter key="use_id_attribute_as_key" value="false"/>
<list key="key_attributes"/>
</operator>
<operator activated="true" breakpoints="after" class="select_attributes" compatibility="5.3.013" expanded="true" height="76" name="Select Attributes (7)" width="90" x="447" y="255">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attributes" value="id|person_type_id|temp_id|att9"/>
</operator>
<connect from_port="input 1" to_op="Select Attributes (8)" to_port="example set input"/>
<connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Join (5)" to_port="right"/>
<connect from_op="Select Attributes (8)" from_port="example set output" to_op="Join (5)" to_port="left"/>
<connect from_op="Join (5)" from_port="join" to_op="Select Attributes (7)" to_port="example set input"/>
<connect from_op="Select Attributes (7)" from_port="example set output" to_port="output 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="source_input 2" spacing="0"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<operator activated="true" breakpoints="after" class="append" compatibility="5.3.013" expanded="true" height="76" name="Append" width="90" x="648" y="30"/>
<connect from_port="example set" to_op="Extract Macro" to_port="example set"/>
<connect from_op="Extract Macro" from_port="example set" to_op="Loop (2)" to_port="input 1"/>
<connect from_op="Loop (2)" from_port="output 1" to_op="Append" to_port="example set 1"/>
<connect from_op="Append" from_port="merged set" 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>
<operator activated="true" breakpoints="after" class="write_csv" compatibility="5.3.013" expanded="true" height="76" name="writePersonref" width="90" x="2055" y="615">
<parameter key="csv_file" value="/home/result.csv"/>
</operator>
<connect from_op="Read Excel" from_port="output" to_op="Loop Examples" to_port="example set"/>
<connect from_op="Loop Examples" from_port="example set" to_op="writePersonref" to_port="input"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
</process>
测试数据只包含2行:第一行:id = 1,att9 = 2,temp_id = 2;第二行:id = 2,att9 = 1,temp_id = 4
正确的结果应包含3行:第一行:id = 1,att9 = 2,temp_id = 2,person_type_id = 3;第二行:id = 1,att9 = 2,temp_id = 2,person_type_id = 3;第三行:id = 2,att9 = 1,temp_id = 2,person_type_id = 3.
由于
答案 0 :(得分:0)
您可以使用Numerical to Polynominal
运算符将整数转换为标称值。 Loop Values
运算符将正常工作。如果你在循环中仍然需要一个整数值,我的建议是创建一个新属性(使用Generate Attributes
),它是原始整数的副本,将其转换为多项式并使用它来控制{{1运营商。
答案 1 :(得分:0)
我做了一些改变。
Loop
Loop Examples
运营商Loop Examples
运算符输出原始示例集
(这是必需的,否则循环出错)Append
移到Loop Examples
运营商这是过程。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.015">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.3.015" expanded="true" name="Process">
<parameter key="resultfile" value="/home/test.res"/>
<process expanded="true">
<operator activated="true" class="read_excel" compatibility="5.3.015" expanded="true" height="60" name="Read Excel" width="90" x="45" y="75">
<parameter key="excel_file" value="D:\stack.xlsx"/>
<list key="annotations"/>
<list key="data_set_meta_data_information"/>
</operator>
<operator activated="true" class="loop_examples" compatibility="5.3.015" expanded="true" height="94" name="Loop Examples" width="90" x="246" y="75">
<process expanded="true">
<operator activated="true" class="multiply" compatibility="5.3.015" expanded="true" height="94" name="Multiply" width="90" x="45" y="30"/>
<operator activated="true" class="extract_macro" compatibility="5.3.015" expanded="true" height="60" name="Extract Macro" width="90" x="45" y="165">
<parameter key="macro" value="macro_value"/>
<parameter key="macro_type" value="data_value"/>
<parameter key="attribute_name" value="att9"/>
<parameter key="example_index" value="%{example}"/>
<list key="additional_macros"/>
</operator>
<operator activated="true" class="filter_example_range" compatibility="5.3.015" expanded="true" height="76" name="Filter Example Range (2)" width="90" x="45" y="255">
<parameter key="first_example" value="%{example}"/>
<parameter key="last_example" value="%{example}"/>
</operator>
<operator activated="true" class="loop" compatibility="5.3.015" expanded="true" height="76" name="Loop (2)" width="90" x="179" y="165">
<parameter key="set_iteration_macro" value="true"/>
<parameter key="iterations" value="%{macro_value}"/>
<process expanded="true">
<operator activated="true" class="generate_data_user_specification" compatibility="5.3.015" expanded="true" height="60" name="Generate Data by User Specification (2)" width="90" x="112" y="300">
<list key="attribute_values">
<parameter key="person_type_id" value="3"/>
</list>
<list key="set_additional_roles"/>
</operator>
<operator activated="false" breakpoints="after" class="select_attributes" compatibility="5.3.015" expanded="true" height="76" name="Select Attributes (8)" width="90" x="179" y="30">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attributes" value="id|temp_id||att9"/>
</operator>
<operator activated="true" class="join" compatibility="5.3.015" expanded="true" height="76" name="Join (5)" width="90" x="246" y="210">
<parameter key="use_id_attribute_as_key" value="false"/>
<list key="key_attributes"/>
</operator>
<operator activated="false" class="select_attributes" compatibility="5.3.015" expanded="true" height="76" name="Select Attributes (7)" width="90" x="447" y="300">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attributes" value="id|person_type_id|temp_id|att9"/>
</operator>
<connect from_port="input 1" to_op="Join (5)" to_port="left"/>
<connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Join (5)" to_port="right"/>
<connect from_op="Join (5)" from_port="join" to_port="output 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="source_input 2" spacing="0"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<connect from_port="example set" to_op="Multiply" to_port="input"/>
<connect from_op="Multiply" from_port="output 1" to_port="example set"/>
<connect from_op="Multiply" from_port="output 2" to_op="Extract Macro" to_port="example set"/>
<connect from_op="Extract Macro" from_port="example set" to_op="Filter Example Range (2)" to_port="example set input"/>
<connect from_op="Filter Example Range (2)" from_port="example set output" to_op="Loop (2)" to_port="input 1"/>
<connect from_op="Loop (2)" from_port="output 1" to_port="output 1"/>
<portSpacing port="source_example set" spacing="0"/>
<portSpacing port="sink_example set" spacing="0"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<operator activated="true" class="append" compatibility="5.3.015" expanded="true" height="76" name="Append" width="90" x="380" y="120"/>
<operator activated="true" class="write_csv" compatibility="5.3.015" expanded="true" height="76" name="writePersonref" width="90" x="514" y="165">
<parameter key="csv_file" value="/home/result.csv"/>
</operator>
<connect from_op="Read Excel" from_port="output" to_op="Loop Examples" to_port="example set"/>
<connect from_op="Loop Examples" from_port="example set" to_port="result 1"/>
<connect from_op="Loop Examples" from_port="output 1" to_op="Append" to_port="example set 1"/>
<connect from_op="Append" from_port="merged set" to_op="writePersonref" to_port="input"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>