Esempio n. 1
0
 /**
  * Given a two d array of doubles, create a table.
  *
  * @param data
  * @return
  */
 public static ExampleTable getTable(
     double[][] data,
     String[] inputNames,
     String[] outputNames,
     int[] inputs,
     int[] outputs,
     int count) {
   Column[] cols = new Column[data.length];
   int index = 0;
   for (int i = 0; i < inputs.length; i++, index++) {
     if (data.length != count) {
       double[] tmp = new double[count];
       System.arraycopy(data[index], 0, tmp, 0, count);
       data[index] = tmp;
     }
     cols[index] = new DoubleColumn(data[index]);
     cols[index].setLabel(inputNames[i]);
   }
   for (int i = 0; i < outputs.length; i++, index++) {
     if (data.length != count) {
       double[] tmp = new double[count];
       System.arraycopy(data[index], 0, tmp, 0, count);
       data[index] = tmp;
     }
     cols[index] = new DoubleColumn(data[index]);
     cols[index].setLabel(outputNames[i]);
   }
   MutableTable mt = new MutableTableImpl(cols);
   ExampleTable et = mt.toExampleTable();
   et.setInputFeatures(inputs);
   et.setOutputFeatures(outputs);
   return et;
 }