Search in sources :

Example 6 with SamplerPlusTree

use of com.amazon.randomcutforest.executor.SamplerPlusTree in project random-cut-forest-by-aws by aws.

the class RandomCutForestTest method setUp.

@BeforeEach
public void setUp() {
    dimensions = 2;
    sampleSize = 256;
    numberOfTrees = 10;
    components = new ComponentList<>();
    for (int i = 0; i < numberOfTrees; i++) {
        CompactSampler sampler = mock(CompactSampler.class);
        when(sampler.getCapacity()).thenReturn(sampleSize);
        RandomCutTree tree = mock(RandomCutTree.class);
        components.add(spy(new SamplerPlusTree<>(sampler, tree)));
    }
    updateCoordinator = spy(new PointStoreCoordinator<>(new PointStore.Builder().dimensions(2).capacity(1).build()));
    traversalExecutor = spy(new SequentialForestTraversalExecutor(components));
    updateExecutor = spy(new SequentialForestUpdateExecutor<>(updateCoordinator, components));
    RandomCutForest.Builder<?> builder = RandomCutForest.builder().dimensions(dimensions).numberOfTrees(numberOfTrees).sampleSize(sampleSize);
    forest = spy(new RandomCutForest(builder, updateCoordinator, components, builder.getRandom()));
    Whitebox.setInternalState(forest, "traversalExecutor", traversalExecutor);
    Whitebox.setInternalState(forest, "updateExecutor", updateExecutor);
}
Also used : RandomCutTree(com.amazon.randomcutforest.tree.RandomCutTree) SequentialForestUpdateExecutor(com.amazon.randomcutforest.executor.SequentialForestUpdateExecutor) CompactSampler(com.amazon.randomcutforest.sampler.CompactSampler) SequentialForestTraversalExecutor(com.amazon.randomcutforest.executor.SequentialForestTraversalExecutor) ShingleBuilder(com.amazon.randomcutforest.util.ShingleBuilder) SamplerPlusTree(com.amazon.randomcutforest.executor.SamplerPlusTree) PointStoreCoordinator(com.amazon.randomcutforest.executor.PointStoreCoordinator) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SamplerPlusTree (com.amazon.randomcutforest.executor.SamplerPlusTree)6 PointStoreCoordinator (com.amazon.randomcutforest.executor.PointStoreCoordinator)3 CompactSampler (com.amazon.randomcutforest.sampler.CompactSampler)3 RandomCutTree (com.amazon.randomcutforest.tree.RandomCutTree)3 ArrayList (java.util.ArrayList)3 Test (org.junit.jupiter.api.Test)3 CommonUtils.checkArgument (com.amazon.randomcutforest.CommonUtils.checkArgument)2 CommonUtils.checkNotNull (com.amazon.randomcutforest.CommonUtils.checkNotNull)2 ComponentList (com.amazon.randomcutforest.ComponentList)2 IComponentModel (com.amazon.randomcutforest.IComponentModel)2 RandomCutForest (com.amazon.randomcutforest.RandomCutForest)2 Config (com.amazon.randomcutforest.config.Config)2 Precision (com.amazon.randomcutforest.config.Precision)2 DiVector (com.amazon.randomcutforest.returntypes.DiVector)2 IStreamSampler (com.amazon.randomcutforest.sampler.IStreamSampler)2 Weighted (com.amazon.randomcutforest.sampler.Weighted)2 CompactSamplerMapper (com.amazon.randomcutforest.state.sampler.CompactSamplerMapper)2 CompactSamplerState (com.amazon.randomcutforest.state.sampler.CompactSamplerState)2 PointStoreMapper (com.amazon.randomcutforest.state.store.PointStoreMapper)2 PointStoreState (com.amazon.randomcutforest.state.store.PointStoreState)2