Package de.jungblut.math

Examples of de.jungblut.math.DoubleVector.toArray()


      outcome.add(new DenseDoubleVector(arr));
    }
    knn.train(features, outcome);

    DoubleVector prediction = knn.predict(new SingleEntryDoubleVector(5));
    assertArrayEquals(new double[] { 1d, 0, 0, 0, 1d }, prediction.toArray());
    prediction = knn.predictProbability(new SingleEntryDoubleVector(5));
    assertArrayEquals(new double[] { 0.5, 0, 0, 0, 0.5 }, prediction.toArray());
  }

  void assertArrayEquals(double[] real, double[] actual) {
View Full Code Here


    knn.train(features, outcome);

    DoubleVector prediction = knn.predict(new SingleEntryDoubleVector(5));
    assertArrayEquals(new double[] { 1d, 0, 0, 0, 1d }, prediction.toArray());
    prediction = knn.predictProbability(new SingleEntryDoubleVector(5));
    assertArrayEquals(new double[] { 0.5, 0, 0, 0, 0.5 }, prediction.toArray());
  }

  void assertArrayEquals(double[] real, double[] actual) {
    assertEquals(real.length, actual.length);
    for (int i = 0; i < real.length; i++) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.