use of com.amazon.randomcutforest.anomalydetection.SimulatedTransductiveScalarScoreVisitor in project random-cut-forest-by-aws by aws.
the class RandomCutForest method getDynamicSimulatedScore.
/**
* Similar to above but now the scoring takes in a function of Bounding Box to
* probabilities (vector over the dimensions); and produces a score af-if the
* tree were built using that function (when in reality the tree is an RCF).
* Changing the defaultRCFgVec function to some other function f() will provide
* a mechanism of dynamic scoring for trees that are built using f() which is
* the purpose of TransductiveScalarScore visitor. Note that the answer is an
* MCMC simulation and is not normalized (because the scoring functions are
* flexible and unknown) and over a small number of trees the errors can be
* large specially if vecSep is very far from defaultRCFgVec
*
* Given the large number of possible sources of distortion, ignoreLeafThreshold
* is not supported.
*
* @param point point to be scored
* @param seen the score function for seen point
* @param unseen score function for unseen points
* @param damp dampening the score for duplicates
* @param vecSep the function of (BoundingBox) -> array of probabilities
* @return the simuated score
*/
public double getDynamicSimulatedScore(float[] point, BiFunction<Double, Double, Double> seen, BiFunction<Double, Double, Double> unseen, BiFunction<Double, Double, Double> damp, Function<IBoundingBoxView, double[]> vecSep) {
if (!isOutputReady()) {
return 0.0;
}
VisitorFactory<Double> visitorFactory = new VisitorFactory<>((tree, y) -> new SimulatedTransductiveScalarScoreVisitor(tree.projectToTree(y), tree.getMass(), seen, unseen, damp, CommonUtils::defaultRCFgVecFunction, vecSep));
BinaryOperator<Double> accumulator = Double::sum;
Function<Double, Double> finisher = sum -> sum / numberOfTrees;
return traverseForest(transformToShingledPoint(point), visitorFactory, accumulator, finisher);
}
Aggregations