Beispiel #1
0
  public boolean runTest(Integer klass) {
    // generate data
    Database<DoublePoint, Integer> data = new SimpleDatabase<DoublePoint, Integer>();
    for (Map.Entry<Integer, PointGenerator> e : gens.entrySet()) {
      data.addAll(e.getValue().generateEntries(n, e.getKey()));
    }

    // create classifier with generated data
    Classifer<DoublePoint, Integer> classifier =
        new SimpleKNNClassifier<DoublePoint, Integer>(k, data);

    // classify a random point
    PointGenerator gen = gens.get(klass);
    DoublePoint p = gen.generate();

    return klass.equals(classifier.classify(p));
  }
  public void generate() {
    rewind();

    mLinePoints = new Point[mLineNumber + 1];

    mLinePoints[0] = ViewTools.getRandomPoint(mBounds);
    mLinePoints[1] = mPointGenerator.makeMap(mLinePoints[0], mLinePoints[0]).getPoint();
    finishGenerate();
  }
  public void generate(Point startPoint, int LineNumber) {
    rewind();

    mLineNumber = LineNumber;

    mLinePoints = new Point[mLineNumber + 1];

    mLinePoints[0] = startPoint;
    mLinePoints[1] = mPointGenerator.makeMap(mLinePoints[0], mLinePoints[0]).getPoint();
    finishGenerate();
  }
 private void finishGenerate() {
   for (int x = 2; x < mLineNumber + 1; x++) {
     mLinePoints[x] = mPointGenerator.makeMap(mLinePoints[x - 2], mLinePoints[x - 1]).getPoint();
   }
   makeCurves();
 }