### Question:
CategoricalPrediction extends Prediction { @Override public synchronized void update(Example train) { CategoricalFeature target = (CategoricalFeature) train.getTarget(); int valueID = target.getValueID(); categoryCounts[valueID]++; setCount(getCount() + 1); recompute(); } CategoricalPrediction(int[] categoryCounts);  CategoricalPrediction(float[] categoryProbabilities); int[] getCategoryCounts(); float[] getCategoryProbabilities(); int getMostProbableCategoryID(); @Override FeatureType getFeatureType(); @Override synchronized void update(Example train); @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.forValue(2)); prediction.update(example); prediction.update(example); assertEquals(2, prediction.getMostProbableCategoryID()); counts[2] += 2; assertArrayEquals(counts, prediction.getCategoryCounts()); assertArrayEquals(new float[] {0.0f, 0.1f, 0.5f, 0.0f, 0.4f, 0.0f}, prediction.getCategoryProbabilities()); }