A program to recognize and reward our most engaged community members
import com.rapidminer.tools.Ontology;ExampleSet exampleSet = input[0];Attributes attributes = exampleSet.getAttributes();Attribute att1 = attributes.get("att1");Attribute att2 = attributes.get("att2");// generate additional attributeAttribute att3 = AttributeFactory.createAttribute("att3", Ontology.REAL);// add new attribute to example setattributes.addRegular(att3);// insert new column into example set's data tableexampleSet.getExampleTable().addAttribute(att3);double sum = 0.0;for (Example example : exampleSet) { double currentValue = example.getValue(att1); sum += currentValue; example.setValue(att2, sum); example.setValue(att3, sum);}return exampleSet;
<?xml version="1.0" encoding="UTF-8" standalone="no"?><process version="5.1.008"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="5.1.008" expanded="true" name="Process"> <process expanded="true" height="116" width="547"> <operator activated="true" class="generate_data" compatibility="5.1.008" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30"> <parameter key="number_examples" value="5"/> <parameter key="number_of_attributes" value="2"/> <parameter key="attributes_lower_bound" value="0.0"/> </operator> <operator activated="true" class="select_attributes" compatibility="5.1.008" expanded="true" height="76" name="Select Attributes" width="90" x="179" y="30"> <parameter key="attribute_filter_type" value="single"/> <parameter key="attribute" value="label"/> <parameter key="invert_selection" value="true"/> <parameter key="include_special_attributes" value="true"/> </operator> <operator activated="true" class="loop_examples" compatibility="5.1.008" expanded="true" height="76" name="Loop Examples" width="90" x="313" y="30"> <process expanded="true" height="607" width="740"> <operator activated="true" class="set_data" compatibility="5.1.008" expanded="true" height="76" name="Set Data" width="90" x="45" y="30"> <parameter key="example_index" value="%{example}"/> <parameter key="attribute_name" value="att2"/> <parameter key="value" value="NaN"/> <list key="additional_values"/> </operator> <connect from_port="example set" 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> <operator activated="true" class="execute_script" compatibility="5.1.008" expanded="true" height="76" name="Execute Script" width="90" x="447" y="30"> <parameter key="script" value="import com.rapidminer.tools.Ontology; ExampleSet exampleSet = input[0]; Attributes attributes = exampleSet.getAttributes(); Attribute att1 = attributes.get("att1"); Attribute att2 = attributes.get("att2"); // generate additional attribute Attribute att3 = AttributeFactory.createAttribute("att3", Ontology.REAL); // add new attribute to example set attributes.addRegular(att3); // insert new column into example set's data table exampleSet.getExampleTable().addAttribute(att3); double sum = 0.0; for (Example example : exampleSet) { 	double currentValue = example.getValue(att1); 	sum += currentValue; 	example.setValue(att2, sum); 	example.setValue(att3, sum); } return exampleSet;"/> </operator> <connect from_op="Generate Data" from_port="output" to_op="Select Attributes" to_port="example set input"/> <connect from_op="Select Attributes" from_port="example set output" to_op="Loop Examples" to_port="example set"/> <connect from_op="Loop Examples" from_port="example set" to_op="Execute Script" to_port="input 1"/> <connect from_op="Execute Script" from_port="output 1" 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>