Exemplo n.º 1
0
  @Override
  public DDAG clone() {
    DDAG clone = new DDAG(baseClassifier.clone(), isConcurrentTraining());
    if (oneVone != null) {
      clone.oneVone = new Classifier[oneVone.length][];
      for (int i = 0; i < oneVone.length; i++) {
        clone.oneVone[i] = new Classifier[oneVone[i].length];
        for (int j = 0; j < oneVone[i].length; j++) clone.oneVone[i][j] = oneVone[i][j].clone();
      }
    }
    if (predicting != null) clone.predicting = predicting.clone();

    return clone;
  }
Exemplo n.º 2
0
  @Test
  public void testClone() {
    System.out.println("clone");

    ClassificationDataSet t1 = FixedProblems.getSimpleKClassLinear(1000, 7);
    ClassificationDataSet t2 = FixedProblems.getSimpleKClassLinear(1000, 9);

    DDAG instance = new DDAG(new DCDs());

    instance = instance.clone();

    instance.trainC(t1);

    DDAG result = instance.clone();
    for (int i = 0; i < t1.getSampleSize(); i++)
      assertEquals(t1.getDataPointCategory(i), result.classify(t1.getDataPoint(i)).mostLikely());
    result.trainC(t2);

    for (int i = 0; i < t1.getSampleSize(); i++)
      assertEquals(t1.getDataPointCategory(i), instance.classify(t1.getDataPoint(i)).mostLikely());

    for (int i = 0; i < t2.getSampleSize(); i++)
      assertEquals(t2.getDataPointCategory(i), result.classify(t2.getDataPoint(i)).mostLikely());
  }