Пример #1
0
  protected HashMap<String, Object> selectAttribute(
      ArrayList<DataInstance> instances, ArrayList<Integer> attributeList) {
    Random r = new Random();
    Integer attr = attributeList.get(r.nextInt(attributeList.size()));

    selectedInstances = new HashMap<Integer, ArrayList<DataInstance>>();
    ArrayList<DataInstance> data;
    for (DataInstance di : instances) {
      int value = di.getAttributes().get(attr.intValue()).intValue();
      if (selectedInstances.containsKey(value)) {
        data = selectedInstances.get(value);
        data.add(di);
        selectedInstances.put(value, data);
      } else {
        data = new ArrayList<DataInstance>();
        data.add(di);
        selectedInstances.put(value, data);
      }
    }

    HashMap<String, Object> choice = new HashMap<String, Object>();
    choice.put("attribute", attr);
    choice.put("discrete", "true");
    choice.put("multiway", "true");
    return choice;
  }
 @Override
 public List<DataInstance> getDataFromFile(String fileName, int inputDim, int outputDim) {
   List<DataInstance> data = new ArrayList<DataInstance>();
   try {
     Scanner scn = new Scanner(new File(fileName));
     while (scn.hasNextLine()) {
       String[] line = scn.nextLine().split("\\s+|,");
       double[] arr = new double[line.length];
       for (int i = 0; i < line.length; i++) arr[i] = Double.parseDouble(line[i]);
       DataInstance d = new DataInstance(inputDim, outputDim, arr);
       double[] out = d.getOutputTruthValue();
       if (out[0] == 1) out = new double[] {1, 0};
       else out = new double[] {0, 1};
       d.replaceOutputTruthValue(out);
       data.add(d);
     }
     scn.close();
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   }
   return data;
 }
Пример #3
0
 @Override
 public void send(Enum<?> msgId, DustObject msgOb, boolean wait, ResponseProcessor respProc) {
   data.send(this, msgId, msgOb, wait, respProc);
 }
Пример #4
0
 @Override
 public DustObject getNeighbor(DustIdentifier typeId) {
   return data.getNeighbor(typeId);
 }
Пример #5
0
 @Override
 public Variant getFieldVariant(int idx) {
   return data.getFieldVariant(idx);
 }
Пример #6
0
 @Override
 public boolean isNull(int idx) {
   return data.isNull(idx);
 }
Пример #7
0
 @Override
 public int getFieldCount() {
   return data.getFieldCount();
 }
Пример #8
0
 @Override
 public DustIdentifier getObTypeID() {
   return data.getObTypeID();
 }
Пример #9
0
 @Override
 public Entity getEntity() {
   return data.getEntity();
 }