### Question:
ClassificationDistribution extends AbstractOryxResource { @GET @Path("{datum}") @Produces({MediaType.TEXT_PLAIN, "text/csv", MediaType.APPLICATION_JSON}) public List<IDValue> get(@PathParam("datum") String datum) throws OryxServingException { check(datum != null && !datum.isEmpty(), "Missing input data"); RDFServingModel model = (RDFServingModel) getServingModel(); InputSchema inputSchema = model.getInputSchema(); check(inputSchema.isClassification(), "Only applicable for classification"); Prediction prediction = model.makePrediction(TextUtils.parseDelimited(datum, ',')); double[] probabilities = ((CategoricalPrediction) prediction).getCategoryProbabilities(); int targetIndex = inputSchema.getTargetFeatureIndex(); CategoricalValueEncodings valueEncodings = model.getEncodings(); Map<Integer,String> targetEncodingName = valueEncodings.getEncodingValueMap(targetIndex); List<IDValue> result = new ArrayList<>(probabilities.length); for (int i = 0; i < probabilities.length; i++) { result.add(new IDValue(targetEncodingName.get(i), probabilities[i])); } return result; }  @GET @Path("{datum}") @Produces({MediaType.TEXT_PLAIN, "text/csv", MediaType.APPLICATION_JSON}) List<IDValue> get(@PathParam("datum") String datum);  }### Answer:
@Test public void testDistribution() { List<IDValue> recs = target("/classificationDistribution/B,0,").request() .accept(MediaType.APPLICATION_JSON_TYPE).get(LIST_ID_VALUE_TYPE); Assert.assertEquals("X", recs.get(0).getID()); Assert.assertEquals((10.0 / 90.0 + 2 * (1000.0 / 111000.0)) / 3, recs.get(0).getValue(), OryxTest.DOUBLE_EPSILON); Assert.assertEquals("Y", recs.get(1).getID()); Assert.assertEquals((30.0 / 90.0 + 2 * (10000.0 / 111000.0)) / 3, recs.get(1).getValue(), OryxTest.DOUBLE_EPSILON); Assert.assertEquals("Z", recs.get(2).getID()); Assert.assertEquals((50.0 / 90.0 + 2 * (100000.0 / 111000.0)) / 3, recs.get(2).getValue(), OryxTest.DOUBLE_EPSILON); }
@Test public void testDistribution2() { List<IDValue> recs = target("/classificationDistribution/A,-5,").request() .accept(MediaType.APPLICATION_JSON_TYPE).get(LIST_ID_VALUE_TYPE); Assert.assertEquals("X", recs.get(0).getID()); Assert.assertEquals((1.0 / 6.0 + 2 * (100.0 / 1400.0)) / 3, recs.get(0).getValue(), OryxTest.DOUBLE_EPSILON); Assert.assertEquals("Y", recs.get(1).getID()); Assert.assertEquals((2.0 / 6.0 + 2 * (400.0 / 1400.0)) / 3, recs.get(1).getValue(), OryxTest.DOUBLE_EPSILON); Assert.assertEquals("Z", recs.get(2).getID()); Assert.assertEquals((3.0 / 6.0 + 2 * (900.0 / 1400.0)) / 3, recs.get(2).getValue(), OryxTest.DOUBLE_EPSILON); }