-
Notifications
You must be signed in to change notification settings - Fork 160
Anomaly Detection Module
While gathering requirements to develop the Java™ version of the Network API, we decided one of the things which was needed was a usage example that could be compared to the Python version. The Python version has a Network API Demo (actually two now) which we decided could be used to demonstrate direct compliance of essential concepts. The demo we chose also demonstrates the use of the Anomaly Prediction functionality - so naturally we simply had to create that too!
So as a result we now have a major piece of functionality added to the "Algorithms" package which contains the classes organized around CLA Classification.
There are 3 explicit modes in which anomaly functionality can be used:
-
Static call to obtain anomaly score.
Ex.
int[] currentlyActiveColumns = { 3, 5, 7 }; // Array containing col indexes
int[] predictedActiveColumns = { 2, 5, 6 };
double score = Anomaly.computeRawAnomalyScore(currentlyActiveColumns, predictedActiveColumns);
-
Factory instantiation of Anomaly instance. (Mode.PURE)
Ex.
Map<String, Object> params = new HashMap<>();
params.put(KEY_MODE, Mode.PURE); // May be Mode.LIKELIHOOD
params.put(KEY_USE_MOVING_AVG, true);
params.put(KEY_WINDOW_SIZE, 10);
params.put(KEY_IS_WEIGHTED, true);
Anomaly anomalyComputer = Anomaly.create(params);
double score = anomalyComputer.compute(currentlyActiveColumns, predictedActiveColumns, 0, 0);
-
Factory instantiation of Anomaly instance. (Mode.LIKELIHOOD)
Ex.
Map<String, Object> params = new HashMap<>();
params.put(KEY_MODE, Mode.LIKELIHOOD);
params.put(KEY_USE_MOVING_AVG, true);
params.put(KEY_WINDOW_SIZE, 10);
params.put(KEY_IS_WEIGHTED, true);
// Collect timestamp, input value (double), score (double) in a List<Sample>
List<Sample> samples = ... // Where Sample = Sample(timestamp, value, score)
Anomaly an = Anomaly.create(params);
AnomalyLikelihoodMetrics metrics = an.estimateAnomalyLikelihoods(samples, 10, 0);
// Above **AnomalyLikelihoodMetrics** contains many statistical goodies.
To update the anomaly computer with new Samples, call:
AnomalyLikelihoodMetrics metrics2 = an.updateAnomalyLikelihoods(<new samples>, metrics.getParams());
For more information regarding usage, please see the tests.
Be sure and keep up on the new Network API package development, monitor #HtmJavaDevUpdates
- Introduction (Home)
- History & News Archives...
- Usability
- Architecture
- NAPI Quick Start Guide
- NAPI In Depth
- Saving Your Network: PersistenceAPI Serialization
- Roadmap
- Browse Java Docs
- Build Instructions
- Eclipse (Dev Setup)
- Anomaly Prediction
- Test Coverage Reports
- [Cortical.io Demos] (https://github.com/numenta/htm.java-examples/tree/master/src/main/java/org/numenta/nupic/examples/cortical_io)
- Hot Gym Demo
- Performance Benchmarks with jmh - blog
- BLOG: Join the "cogmission"