Ejemplo n.º 1
0
  public TrainingSet buildTSet(TrainingSet tSet, double[] w) {

    WeightBasedRandom wRnd = new WeightBasedRandom(w);

    int n = w.length;

    Instance[] sample = new Instance[n];

    Map<Integer, Instance> instances = tSet.getInstances();

    for (int i = 0; i < n; i++) {
      int instanceIndex = wRnd.nextInt();
      sample[i] = instances.get(instanceIndex);
    }

    return new TrainingSet(sample);
  }