public void accept()

in Java/core/src/main/java/com/amazon/randomcutforest/anomalydetection/AbstractAttributionVisitor.java [113:166]


    public void accept(INodeView node, int depthOfNode) {
        if (pointInsideBox) {
            return;
        }

        IBoundingBoxView smallBox;

        if (hitDuplicates || ignoreLeaf) {
            // use the sibling bounding box to represent counterfactual "what if point & the
            // candidate near neighbor
            // had not been inserted in the tree"

            shadowBox = shadowBox == null ? node.getSiblingBoundingBox(pointToScore)
                    : shadowBox.getMergedBox(node.getSiblingBoundingBox(pointToScore));

            smallBox = shadowBox;
        } else {
            smallBox = node.getBoundingBox();
        }

        IBoundingBoxView largeBox = smallBox.getMergedBox(pointToScore);
        updateRangesForScoring(smallBox, largeBox);

        double probOfCut = sumOfDifferenceInRange / sumOfNewRange;

        // if leaves were ignored we need to keep accounting for the score
        if (ignoreLeaf) {
            savedScore = probOfCut * scoreUnseen(depthOfNode, node.getMass()) + (1 - probOfCut) * savedScore;
        }

        if (probOfCut <= 0) {
            pointInsideBox = true;
        } else {
            double newScore = scoreUnseen(depthOfNode, node.getMass());

            for (int i = 0; i < pointToScore.length; i++) {
                double probOfCutInSpikeDirection = differenceInRangeVector[2 * i] / sumOfNewRange;
                directionalAttribution.high[i] = probOfCutInSpikeDirection * newScore
                        + (1 - probOfCut) * directionalAttribution.high[i];

                double probOfCutInDipDirection = differenceInRangeVector[2 * i + 1] / sumOfNewRange;
                directionalAttribution.low[i] = probOfCutInDipDirection * newScore
                        + (1 - probOfCut) * directionalAttribution.low[i];
            }
        }

        if ((hitDuplicates || ignoreLeaf) && (pointInsideBox || depthOfNode == 0)) {
            // final rescaling; this ensures agreement with the ScalarScoreVector
            // the scoreUnseen/scoreSeen should be the same as scoring; other uses need
            // caution.
            directionalAttribution.renormalize(savedScore);

        }
    }