* @param className the class name
* @param attributeList the attribute list
* @return the weka data from u matrix
*/
public Instances getWekaDataFromUMatrix( String className, String[] attributeList ){
Unit ships = TDB.This().get("TDBROOT.MODEL.WORLD.SHIPS");
//////////////////////////////////////////////////////////////////////////////////////////
//create attributes list
ArrayList<Attribute> atts = new ArrayList<Attribute>();
SortableValueMap<String, ArrayList<String>> mapValues = new SortableValueMap<String, ArrayList<String>>();
for( String strAtrribute : attributeList){
ArrayList<String> values = new ArrayList<String>();
mapValues.put(strAtrribute, values);
}
for( Unit s : ships.list ){
for( String strAtrribute : attributeList){
Unit c = s.get(strAtrribute);
ArrayList<String> values = mapValues.get(strAtrribute);
//fill all data to matrix
for( Integer t = 0; t < RDB.This().getTime(); t++ ){
String d = c.getNominal(t);
if( !values.contains(d) && d != null )
values.add(d);
}
}
}
for( String strAtrribute : attributeList){
ArrayList<String> values = mapValues.get(strAtrribute);
atts.add(new Attribute(strAtrribute, values));
}
//////////////////////////////////////////////////////////////////////////////////////////
//create Instances object
Instances data = new Instances("MyRelation", atts, 0);
//////////////////////////////////////////////////////////////////////////////////////////
//fill all matrix data to weka data
for( Unit s : ships.list ){
for( Integer t = 0; t < RDB.This().getTime(); t++ ){
double[] vals = new double[data.numAttributes()];
int j = 0;
for( String strAtrribute : attributeList){
Unit c = s.get(strAtrribute);
ArrayList<String> values = mapValues.get(strAtrribute);
String d = c.getNominal(t);
vals[j++] = values.indexOf(d);
}
// add