A program to recognize and reward our most engaged community members
import com.rapidminer.example.*;import com.rapidminer.example.table .*;import com.rapidminer.example.set .*;import com.rapidminer.tools .Ontology;import java.util.*;public class CreatingExampleTables { public static void main(String [] argv) { // create attribute list List <Attribute> attributes = new LinkedList<Attribute>(); for ( int a = 0; a < getMyNumOfAttributes(); a++) { attributes.add( AttributeFactory . createAttribute (”att” + a, Ontology.REAL)); } Attribute label = AttributeFactory . createAttribute (” label ”, Ontology.NOMINAL)); attributes.add(label); //create table MemoryExampleTable table = new MemoryExampleTable(attributes); // fill table (here : only real values ) for (int d = 0; d < getMyNumOfDataRows(); d++) { double[] data = new double[attributes.size()]; for (int a = 0; a < getMyNumOfAttributes(); a++) { //fill with proper data here data = getMyValue(d, a); } // maps the nominal classification to a double value data[data.length - 1] = label.getMapping().mapString(getMyClassification(d)); //add data row table.addDataRow(new DoubleArrayDataRow(data)); } // create example set ExampleSet exampleSet = table.createExampleSet(label); }}
import com.rapidminer.tools.Ontology;import com.rapidminer.operator.learner.associations.*;AssociationRules rules = input[0];// construct attribute setAttribute[] attributes= new Attribute[11];attributes[0] = AttributeFactory.createAttribute("Premise", Ontology.STRING);attributes[1] = AttributeFactory.createAttribute("Premise Items", Ontology.INTEGER);attributes[2] = AttributeFactory.createAttribute("Conclusion", Ontology.STRING);attributes[3] = AttributeFactory.createAttribute("Conclusion Items", Ontology.INTEGER);attributes[4] = AttributeFactory.createAttribute("Confidence", Ontology.REAL);attributes[5] = AttributeFactory.createAttribute("Conviction", Ontology.REAL);attributes[6] = AttributeFactory.createAttribute("Gain", Ontology.REAL);attributes[7] = AttributeFactory.createAttribute("Laplace", Ontology.REAL);attributes[8] = AttributeFactory.createAttribute("Lift", Ontology.REAL);attributes[9] = AttributeFactory.createAttribute("Ps", Ontology.REAL);attributes[10] = AttributeFactory.createAttribute("Total Support", Ontology.REAL);MemoryExampleTable table = new MemoryExampleTable(attributes);DataRowFactory ROW_FACTORY = new DataRowFactory(0);String[] strings= new String[11];for (AssociationRule rule : rules) { // construct example data strings[0]=rule.toPremiseString(); strings[1]=rule.premise.size().toString(); strings[2]=rule.toConclusionString(); strings[3]=rule.conclusion.size().toString(); strings[4]=rule.getConfidence().toString(); strings[5]=rule.getConviction().toString(); strings[6]=rule.getGain().toString(); strings[7]=rule.getLaplace().toString(); strings[8]=rule.getLift().toString(); strings[9]=rule.getPs().toString(); strings[10]=rule.getTotalSupport().toString(); // make and add row DataRow row = ROW_FACTORY.create(strings, attributes); table.addDataRow(row); }ExampleSet exampleSet = table.createExampleSet();return exampleSet;