Search in sources :

Example 1 with SmallTrainingDatasetSizeException

use of org.apache.ignite.ml.math.exceptions.knn.SmallTrainingDatasetSizeException in project ignite by apache.

the class KNNClassificationTest method testLargeKValue.

/**
 */
public void testLargeKValue() {
    IgniteUtils.setCurrentIgniteName(ignite.configuration().getIgniteInstanceName());
    double[][] mtx = new double[][] { { 10.0, 10.0 }, { 10.0, 20.0 }, { -1, -1 }, { -2, -2 }, { -1.0, -2.0 }, { -2.0, -1.0 } };
    double[] lbs = new double[] { 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
    LabeledDataset training = new LabeledDataset(mtx, lbs);
    try {
        new KNNModel(7, new EuclideanDistance(), KNNStrategy.SIMPLE, training);
        fail("SmallTrainingDatasetSizeException");
    } catch (SmallTrainingDatasetSizeException e) {
        return;
    }
    fail("SmallTrainingDatasetSizeException");
}
Also used : EuclideanDistance(org.apache.ignite.ml.math.distances.EuclideanDistance) SmallTrainingDatasetSizeException(org.apache.ignite.ml.math.exceptions.knn.SmallTrainingDatasetSizeException) KNNModel(org.apache.ignite.ml.knn.models.KNNModel) LabeledDataset(org.apache.ignite.ml.structures.LabeledDataset)

Aggregations

KNNModel (org.apache.ignite.ml.knn.models.KNNModel)1 EuclideanDistance (org.apache.ignite.ml.math.distances.EuclideanDistance)1 SmallTrainingDatasetSizeException (org.apache.ignite.ml.math.exceptions.knn.SmallTrainingDatasetSizeException)1 LabeledDataset (org.apache.ignite.ml.structures.LabeledDataset)1