An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
<?xml version="1.0" encoding="UTF-8" standalone="no"?><process version="5.3.009"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="5.3.009" expanded="true" name="Process"> <process expanded="true"> <operator activated="true" class="generate_data" compatibility="5.3.009" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30"> <parameter key="number_examples" value="1"/> <parameter key="number_of_attributes" value="1"/> </operator> <operator activated="true" class="execute_script" compatibility="5.3.009" expanded="true" height="76" name="Execute Script" width="90" x="179" y="30"> <parameter key="script" value="import java.util.Map; import java.util.Map.Entry; import java.util.Iterator; import java.util.LinkedHashMap; import com.rapidminer.example.Attribute; import com.rapidminer.example.Example; import com.rapidminer.example.ExampleSet; import com.rapidminer.example.table.AttributeFactory; import com.rapidminer.tools.Ontology; ExampleSet exampleSet = input[0]; Map<Attribute, Attribute> translationMap = new LinkedHashMap<Attribute, Attribute>(); Iterator<Attribute> iterator = exampleSet.getAttributes().iterator(); while (iterator.hasNext()) { 	Attribute oldAtt = iterator.next(); 	if (Ontology.ATTRIBUTE_VALUE_TYPE.isA(oldAtt.getValueType(), Ontology.NUMERICAL)) { 		Attribute newAtt = AttributeFactory.createAttribute(Ontology.BINOMINAL); 		translationMap.put(oldAtt, newAtt); 	} 	// your other conditions here } // adding to table and exampleSet for (Entry<Attribute, Attribute> replacement: translationMap.entrySet()) { 	Attribute newAttribute = replacement.getValue(); 	exampleSet.getExampleTable().addAttribute(newAttribute); 	exampleSet.getAttributes().addRegular(newAttribute); } 		 // over all examples change attribute values for(Example example : exampleSet) { 	for(Entry<Attribute, Attribute> replacement: translationMap.entrySet()) { 		Attribute oldAttribute = replacement.getKey(); 		Attribute newAttribute = replacement.getValue(); 		double oldValue = example.getValue(oldAttribute); 		if (Double.isNaN(oldValue)) { 			example.setValue(newAttribute, Double.NaN); 		} else { // your conditions here 			example.setValue(newAttribute, newAttribute.getMapping().mapString("yourString")); 		} 	} } 		 // removing old attributes for (Map.Entry<Attribute,Attribute> entry : translationMap.entrySet()) { 	Attribute originalAttribute = entry.getKey(); 	exampleSet.getAttributes().remove(originalAttribute); 	entry.getValue().setName(originalAttribute.getName()); } return exampleSet;"/> </operator> <connect from_op="Generate Data" from_port="output" 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>