Search in sources :

Example 6 with DensityOutput

use of com.amazon.randomcutforest.returntypes.DensityOutput in project random-cut-forest-by-aws by aws.

the class RandomCutForestShingledBenchmark method basicDensityAndUpdate.

@Benchmark
@OperationsPerInvocation(DATA_SIZE)
public RandomCutForest basicDensityAndUpdate(BenchmarkState state, Blackhole blackhole) {
    double[][] data = state.data;
    forest = state.forest;
    DensityOutput output = new DensityOutput(forest.getDimensions(), forest.getSampleSize());
    for (int i = INITIAL_DATA_SIZE; i < data.length; i++) {
        output = forest.getSimpleDensity(data[i]);
        forest.update(data[i]);
    }
    blackhole.consume(output);
    return forest;
}
Also used : DensityOutput(com.amazon.randomcutforest.returntypes.DensityOutput) Benchmark(org.openjdk.jmh.annotations.Benchmark) OperationsPerInvocation(org.openjdk.jmh.annotations.OperationsPerInvocation)

Example 7 with DensityOutput

use of com.amazon.randomcutforest.returntypes.DensityOutput in project random-cut-forest-by-aws by aws.

the class RandomCutForestFunctionalTest method testSimpleDensity.

@ParameterizedTest
@ArgumentsSource(TestForestProvider.class)
public void testSimpleDensity(RandomCutForest forest) {
    DensityOutput output1 = forest.getSimpleDensity(new double[] { 0.0, 0.0, 0.0 });
    DensityOutput output2 = forest.getSimpleDensity(new double[] { 6.0, 6.0, 0.0 });
    DensityOutput output3 = forest.getSimpleDensity(new double[] { -4.0, -4.0, 0.0 });
    DensityOutput output4 = forest.getSimpleDensity(new double[] { -6.0, -6.0, 0.0 });
    assertTrue(output1.getDensity(0.001, 3) > output2.getDensity(0.001, 3));
    assertTrue(output1.getDensity(0.001, 3) > output3.getDensity(0.001, 3));
    assertTrue(output1.getDensity(0.001, 3) > output4.getDensity(0.001, 3));
    assertTrue(output3.getDensity(0.001, 3) > output4.getDensity(0.001, 3));
}
Also used : DensityOutput(com.amazon.randomcutforest.returntypes.DensityOutput) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource)

Example 8 with DensityOutput

use of com.amazon.randomcutforest.returntypes.DensityOutput in project random-cut-forest-by-aws by aws.

the class RandomCutForestBenchmark method basicDensityAndUpdate.

@Benchmark
@OperationsPerInvocation(DATA_SIZE)
public RandomCutForest basicDensityAndUpdate(BenchmarkState state, Blackhole blackhole) {
    double[][] data = state.data;
    forest = state.forest;
    DensityOutput output = new DensityOutput(forest.getDimensions(), forest.getSampleSize());
    for (int i = INITIAL_DATA_SIZE; i < data.length; i++) {
        output = forest.getSimpleDensity(data[i]);
        forest.update(data[i]);
    }
    blackhole.consume(output);
    return forest;
}
Also used : DensityOutput(com.amazon.randomcutforest.returntypes.DensityOutput) Benchmark(org.openjdk.jmh.annotations.Benchmark) OperationsPerInvocation(org.openjdk.jmh.annotations.OperationsPerInvocation)

Aggregations

DensityOutput (com.amazon.randomcutforest.returntypes.DensityOutput)8 InterpolationMeasure (com.amazon.randomcutforest.returntypes.InterpolationMeasure)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)2 Benchmark (org.openjdk.jmh.annotations.Benchmark)2 OperationsPerInvocation (org.openjdk.jmh.annotations.OperationsPerInvocation)2 RandomCutForest (com.amazon.randomcutforest.RandomCutForest)1 SamplerPlusTree (com.amazon.randomcutforest.executor.SamplerPlusTree)1 SimpleInterpolationVisitor (com.amazon.randomcutforest.interpolation.SimpleInterpolationVisitor)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1