-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTM community detector (py3) #5
Conversation
install htm.core detector from setup.py if installed, just skip, otherwise build from github
runable POC for community HTM detector from famous htm.core repo!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review with planned work to do.
If you have time, @dkeeney @ctrl-z-9000-times please have a look at the TODOs, I'll be implementing some here, some to htm.core
|
||
def getAdditionalHeaders(self): | ||
"""Returns a list of strings.""" | ||
return ["raw_score"] #TODO add "prediction" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO output also predictions
rawScore = 0.5 #FIXME result.inferences["anomalyScore"] | ||
|
||
# Update min/max values and check if there is a spatial anomaly | ||
spatialAnomaly = False #TODO make this computed in SP (and later improve) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I like the idea of SpatialAnomaly being moved to SP itself SP return const random representation on empty input & SP anomaly htm.core#550
- I don't 100% like the current implementation of spatial anomalies, but that can be improved later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in htm-community/htm.core#587
# Compute log(anomaly likelihood) | ||
anomalyScore = self.anomalyLikelihood.anomalyProbability(inputData["value"], rawScore, inputData["timestamp"]) | ||
logScore = self.anomalyLikelihood.computeLogLikelihood(anomalyScore) | ||
finalScore = logScore #TODO returls logScore and not probability? Fix that in our Likelihood.cpp; #TODO TM to provide anomaly {none, raw, likelihood} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- we should probably return logScore in Likelihood by default review and refactor AnomalyLikelihood code (both c++, python) htm.core#469
- provide enum modes {none, raw, likelihood} to
TM.anomaly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both done in htm-community/htm.core#588
|
||
curr_dir = os.getcwd() | ||
os.chdir(REPO_DIR) | ||
os.system("git clone --depth=5 https://github.com/htm-community/htm.core") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when htm.core can be available on PyPI, skip all this mess htm-community/htm.core#19
@@ -159,7 +159,7 @@ def main(args): | |||
parser.add_argument("-d", "--detectors", | |||
nargs="*", | |||
type=str, | |||
default=["numenta", "numentaTM", "htmjava", "null", "random", | |||
default=["numenta", "numentaTM", "htmcore", "htmjava", "null", "random", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new htmcore
detector!
params and initialization same as in hotgym.py example in htm.core repo. With one expection: RDSE resulotion changed to match one of numenta_detector, not the former value swarmed in hotgym.
implemented the model and runs nice! (Model same as hotgym.py)
as unused in this (cleaner) HTM model.
not so good, need to optimize parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new NAB detector with our community HTM implementation (htmcore
) is ready.
@dkeeney @ctrl-z-9000-times please review, everything is working, additional task would be improving params for our model
| [KNN CAD](https://github.com/htm-community/NAB/tree/master/nab/detectors/knncad)† | 58.0 | 43.4 | 64.8 | | | | ||
| [Relative Entropy](http://www.hpl.hp.com/techreports/2011/HPL-2011-8.pdf) | 54.6 | 47.6 | 58.8 | | | | ||
| [Random Cut Forest](http://proceedings.mlr.press/v48/guha16.pdf) **** | 51.7 | 38.4 | 59.7 | | | | ||
| [htm.core](https://github.com/htm-community/htm.core/) | 50.83 | 49.95 | 52.64 | `htmcore` | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first shot results are not really good, we have to pump it up guys! 📌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed commit that uses numenta_detector
's params, currently running benchmarks
SPATIAL_TOLERANCE = 0.05 | ||
|
||
## parameters to initialize our HTM model (encoder, SP, TM, AnomalyLikelihood) | ||
# TODO optional: optimize these params, either manually and/or swarming. But first keep comparable to numenta_detector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO optimize params taken from hotgym
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters for the original NAB are written down, somewhere in the original nupic
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters for the original NAB
yes, I've created params from the orig nab numenta_detector. But we do not score as well (localAreaDensity instead of removed numActiveColsPerInhArea, more importantly removed BacktrackingTM, which had best results on NAB,...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, ive started looking at and playing with these parameters, and wow it runs fast! I am optimizing a few of the parameters by hand and will push the results soon. Then i can see about hooking this up to the optimization framework
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am optimizing a few of the parameters by hand and will push the results soon
please do. I've been trying to do some hand-optimizations, but I was still getting much worse results than Numenta's HTM :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the new current score. It's just a few points less than the target.
- "reward_low_FN_rate": 66.1922106936328,
- "reward_low_FP_rate": 58.7930712907694,
- "standard": 63.081419488725054
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new current score. It's just a few points less than the target.
that does look good! 👍 Let's merge this so we can go from there..
for information only, not used
use the same params as much as possible to have comparison, print statistics
FIXME for anomaly computation is not needed, as TM provides TM.anomaly already!
Adds
htm.core
https://github.com/htm-community/htm.core as a detectorCurrently WIP,
please review after #2 is merged as this builds atop that.Features
native htm.core improvements
python3
installs htm.core seamlessly
finish the
HtmcoreDetector
detectorrun on all data and commit results
TODO optional in separate PRs
For numenta#337 where it should be then submitted as well
Fixes htm-community/htm.core#205