Object Detection using Template

- Main Page
- Packages
- Classes
- Files

- File List

All Classes Namespaces Files Functions Variables
CreatingExampleTables.java
Go to the documentation of this file.
1 package cz.vutbr.feec.novak68;
2
3 import java.util.LinkedList;
4 import java.util.List;
5 import java.util.Random;
6
7 import com.rapidminer.example.Attribute;
8 import com.rapidminer.example.Example;
9 import com.rapidminer.example.ExampleSet;
10 import com.rapidminer.example.table.AttributeFactory;
11 import com.rapidminer.example.table.DoubleArrayDataRow;
12 import com.rapidminer.example.table.MemoryExampleTable;
13 import com.rapidminer.tools.Ontology;
14
19 public class CreatingExampleTables {
20
21 static List <Attribute> attributes = new LinkedList<Attribute>();
22 public static void main(String[] args) {
23 // create attribute list
24 attributes.add(AttributeFactory.createAttribute("Coordinates", Ontology.STRING));
25 attributes.add(AttributeFactory.createAttribute("simpleC", Ontology.REAL));
26 attributes.add(AttributeFactory.createAttribute("symetryC", Ontology.REAL));
27 attributes.add(AttributeFactory.createAttribute("xSymetry", Ontology.INTEGER));
28 attributes.add(AttributeFactory.createAttribute("ySymetry", Ontology.INTEGER));
29 attributes.add(AttributeFactory.createAttribute("allElementC", Ontology.INTEGER));
30 attributes.add(AttributeFactory.createAttribute("hElementC", Ontology.INTEGER));
31 attributes.add(AttributeFactory.createAttribute("vElementC", Ontology.INTEGER));
32 attributes.add(AttributeFactory.createAttribute("otherElementC", Ontology.INTEGER));
33
34
35 // Attribute label = AttributeFactory . createAttribute (" label ", Ontology.NOMINAL));
36 // attributes.add(label);
37 //create table
38 MemoryExampleTable table = new MemoryExampleTable(attributes);
39 // fill table (here : only real values )
40 for (int d = 0; d < getMyNumOfDataRows(); d++) {
41 double[] data = new double[attributes.size()];
42 for (int a = 0; a < getMyNumOfAttributes(); a++) {
43 //fill with proper data here
44 data[a] = (new Random()).nextDouble();
45 }
46 // maps the nominal classification to a double value
47 // data[data.length - 1] = label.getMapping().mapString(getMyClassification(d));
48 //add data row
49 table.addDataRow(new DoubleArrayDataRow(data));
50 }
51 // create example set
52 ExampleSet exampleSet = table.createExampleSet();
53
54 for (Example example : exampleSet) {
55 String file = example.getValueAsString(exampleSet.getAttributes().get("simpleC"));
56 System.out.println(file);
57 }
58 }
59
60 private static int getMyNumOfAttributes() {
61 // TODO Auto-generated method stub
62 return attributes.size();
63 }
64
65 private static int getMyNumOfDataRows() {
66 return 9;
67 }
68
69 }
cz.vutbr.feec.novak68.CreatingExampleTables.main
static void main(String[] args)
Definition: CreatingExampleTables.java:22
cz.vutbr.feec.novak68.CreatingExampleTables
Definition: CreatingExampleTables.java:19
cz.vutbr.feec.novak68.CreatingExampleTables.getMyNumOfAttributes
static int getMyNumOfAttributes()
Definition: CreatingExampleTables.java:60
cz.vutbr.feec.novak68.CreatingExampleTables.getMyNumOfDataRows
static int getMyNumOfDataRows()
Definition: CreatingExampleTables.java:65