@@ -0,0 +1,2660 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.facebook.presto.ml;%0A%0Aimport com.facebook.presto.metadata.MetadataManager;%0Aimport com.facebook.presto.metadata.Signature;%0Aimport com.facebook.presto.operator.Page;%0Aimport com.facebook.presto.operator.RowPageBuilder;%0Aimport com.facebook.presto.operator.aggregation.Accumulator;%0Aimport com.facebook.presto.operator.aggregation.AggregationFunction;%0Aimport com.facebook.presto.spi.block.Block;%0Aimport com.fasterxml.jackson.core.JsonProcessingException;%0Aimport com.google.common.base.Optional;%0Aimport com.google.common.base.Splitter;%0Aimport com.google.common.collect.ImmutableList;%0Aimport org.testng.annotations.Test;%0A%0Aimport java.util.List;%0A%0Aimport static com.facebook.presto.spi.type.BigintType.BIGINT;%0Aimport static com.facebook.presto.spi.type.VarcharType.VARCHAR;%0Aimport static org.testng.Assert.assertEquals;%0A%0Apublic class TestEvaluateClassifierPredictions%0A%7B%0A    @Test%0A    public void testEvaluateClassifierPredictions()%0A            throws Exception%0A    %7B%0A        MetadataManager metadata = new MetadataManager();%0A        metadata.addFunctions(new MLFunctionFactory().listFunctions());%0A        AggregationFunction aggregation = metadata.getExactFunction(new Signature(%22evaluate_classifier_predictions%22, VARCHAR, BIGINT, BIGINT)).getAggregationFunction();%0A        Accumulator accumulator = aggregation.createAggregation(Optional.%3CInteger%3Eabsent(), Optional.%3CInteger%3Eabsent(), 1.0, 0, 1);%0A        accumulator.addInput(getPage());%0A        Block block = accumulator.evaluateFinal();%0A%0A        String output = block.getSlice(0).toStringUtf8();%0A        List%3CString%3E parts = ImmutableList.copyOf(Splitter.on('%5Cn').split(output));%0A        assertEquals(parts.size(), 3);%0A        assertEquals(parts.get(0), %22Accuracy: 1/2 (50.00%25)%22);%0A        assertEquals(parts.get(1), %22Precision: 1/1 (100.00%25)%22);%0A        assertEquals(parts.get(2), %22Recall: 1/2 (50.00%25)%22);%0A    %7D%0A%0A    private static Page getPage()%0A            throws JsonProcessingException%0A    %7B%0A        return RowPageBuilder.rowPageBuilder(BIGINT, BIGINT)%0A                .row(1, 1)%0A                .row(1, 0)%0A                .build();%0A    %7D%0A%7D%0A

Add unit test for evaluate_classifier_predictions