### Question:
KnnClassifier implements Classifier<KnnModel> { public KnnClassifier(int k) { Validate.isTrue(k > 0, "k must be greater zero"); this.k = k; } KnnClassifier(int k);  KnnClassifier(); @Override CategoryEntries classify(FeatureVector featureVector, KnnModel model); @Override String toString();  }### Answer:
@Test public void testKnnClassifier() { List<Instance> trainingInstances = new ArrayList<>(); trainingInstances.add(new InstanceBuilder().set("f1", 3d).set("f2", 4d).set("f3", 5d).create("A")); trainingInstances.add(new InstanceBuilder().set("f1", 3d).set("f2", 6d).set("f3", 6d).create("A")); trainingInstances.add(new InstanceBuilder().set("f1", 4d).set("f2", 4d).set("f3", 4d).create("B")); KnnLearner knnLearner = new KnnLearner(new NoNormalizer()); KnnModel model = knnLearner.train(trainingInstances); FeatureVector featureVector = new InstanceBuilder().set("f1", 1d).set("f2", 2d).set("f3", 3d).create(); assertEquals(2, model.getCategories().size()); assertTrue(model.getCategories().contains("A")); assertTrue(model.getCategories().contains("B")); CategoryEntries result = new KnnClassifier(3).classify(featureVector, model); assertEquals("A", result.getMostLikelyCategory()); }