### Question:
CategoricalPrediction extends Prediction { @Override public void update(Example train) { CategoricalFeature target = (CategoricalFeature) train.getTarget(); update(target.getEncoding(), 1); } CategoricalPrediction(int[] categoryCounts);  CategoricalPrediction(double[] categoryCounts); double[] getCategoryCounts(); double[] getCategoryProbabilities(); int getMostProbableCategoryEncoding(); @Override FeatureType getFeatureType(); @Override void update(Example train); synchronized void update(int encoding, int count); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void testUpdate() { int[] counts = { 0, 1, 3, 0, 4, 0 }; CategoricalPrediction prediction = new CategoricalPrediction(counts); Example example = new Example(CategoricalFeature.forEncoding(2)); prediction.update(example); prediction.update(example); assertEquals(2, prediction.getMostProbableCategoryEncoding()); counts[2] += 2; assertArrayEquals(toDoubles(counts), prediction.getCategoryCounts()); assertArrayEquals(new double[] {0.0, 0.1, 0.5, 0.0, 0.4, 0.0}, prediction.getCategoryProbabilities()); }