use of com.amazon.randomcutforest.anomalydetection.AnomalyAttributionVisitor in project random-cut-forest-by-aws by aws.
the class RandomCutForest method getApproximateAnomalyAttribution.
public DiVector getApproximateAnomalyAttribution(float[] point) {
if (!isOutputReady()) {
return new DiVector(dimensions);
}
IVisitorFactory<DiVector> visitorFactory = new VisitorFactory<>((tree, y) -> new AnomalyAttributionVisitor(tree.projectToTree(y), tree.getMass()), (tree, x) -> x.lift(tree::liftFromTree));
ConvergingAccumulator<DiVector> accumulator = new OneSidedConvergingDiVectorAccumulator(dimensions, DEFAULT_APPROXIMATE_ANOMALY_SCORE_HIGH_IS_CRITICAL, DEFAULT_APPROXIMATE_DYNAMIC_SCORE_PRECISION, DEFAULT_APPROXIMATE_DYNAMIC_SCORE_MIN_VALUES_ACCEPTED, numberOfTrees);
Function<DiVector, DiVector> finisher = x -> x.scale(1.0 / accumulator.getValuesAccepted());
return traverseForest(transformToShingledPoint(point), visitorFactory, accumulator, finisher);
}
use of com.amazon.randomcutforest.anomalydetection.AnomalyAttributionVisitor in project random-cut-forest-by-aws by aws.
the class RandomCutForest method getAnomalyAttribution.
public DiVector getAnomalyAttribution(float[] point) {
// getAnomalyScore
if (!isOutputReady()) {
return new DiVector(dimensions);
}
IVisitorFactory<DiVector> visitorFactory = new VisitorFactory<>((tree, y) -> new AnomalyAttributionVisitor(tree.projectToTree(y), tree.getMass()), (tree, x) -> x.lift(tree::liftFromTree));
BinaryOperator<DiVector> accumulator = DiVector::addToLeft;
Function<DiVector, DiVector> finisher = x -> x.scale(1.0 / numberOfTrees);
return traverseForest(transformToShingledPoint(point), visitorFactory, accumulator, finisher);
}
Aggregations