Please throw me a clue: finding anomaly _likelihood_

Copied from other thread

Hey @phil_d_cat you switch topics too fast! :slight_smile:

Anomaly-likelihood is not automatically configured with this first version of HTM.Java’s Network API “Anomaly Detection Feature”. For now, there is simply the anomaly score that is available. However, the NAPI includes a way to insert your own “nodes” (custom nodes) into the processing chain, which could handle Anomaly-Likelihood calculations, if you wanted to write your own node for that.

In fact, inserting “custom” nodes is really easy in HTM.Java! Check out this test, for an example.

The “Inference” object also has a method called Inference.getCustomObject() which can be used to retrieve an object inserted into the Inference by the custom “node” (Func or “function” object), see below (as excerpted from the above mentioned test):

        // Here's the "Func1" object (node added below in: .add(addedFunc) )
        // This example takes in a ManualInput (mutable subclass of Inference), and returns a ManualInput.
        // Below it simply returns a String. where "I" is the "Inference" object and I.customObject() takes in any
        // object (i.e. your custom Anomaly-Likelihood result) and returns the Inference or ManualInput itself.
        Func1<ManualInput, ManualInput> addedFunc = I -> { 
            // Do your Anomaly Likelihood work here?
            return I.customObject("Interposed: " + Arrays.toString(I.getSDR()));
        };

        Network n = Network.create("Generic Test", p)
            .add(Network.createRegion("R1")
                .add(Network.createLayer("L1", p)
                    .add(addedFunc)                // <--- Just insert your function
                    .add(new SpatialPooler())));

Anomaly-Likelihood has extensive tests which can be referred to (see here)

You will have to talk to the Numenta engineers to learn how to use the Anomaly-Likelihood feature (how to track and feed data back in). But all you would do is instantiate your Anomaly-Likelihood object and use it in the above function.

Easy peasy? :slight_smile:

(Hint: Try inserting your anomaly experimental code directly into the above mentioned test, that way you can experiment with it and run it?) You’ll need to add a TemporalMemory() also because the above test doesn’t include one.

Cheers,
David