Does the current community version fully support NAB in Python 3.6?

#1

Dear community members,

Thanks for your work. I have gone through several lately updated topics in the forum. But still, I am a little confused about the progress of the community fork.

I am trying to test the Numenta Anomaly Benchmark (NAB) with Python 3.6, which sadly only officially supports Python 2.7. It seems that the code for data, metric/scores, visualization, and detector wrappers are all easy to adapt or rewrite.

However, I am not sure about the code implementing Numenta detector and NumentaTM detector in Github: NAB/nab/detectors/numenta/, and more specifically whether the community version of nupic has the full functionality required for the two detectors.

If I got this correctly, the community version completely rewrote the code in C++ and intended to provide Python 2/3 wrappers (and wrappers for other popular languages) and Network APIs. But I am not certain about the progress.

Based on the import lines below, could you please tell me whether I am able to rewrite the code in Python 3.6 with nupic.py in nupic.cpp (/htm.py in htm.cpp) of the community version? If it is feasible, that would be great!

Besides, If the relevant interfaces are slightly modified, I will be really grateful if you could refer me to the API docs and module names if inconsistent. I will read and try to figure out how to use them by myself.

The import lines are as follows:

from nupic.algorithms import anomaly_likelihood
from nupic.frameworks.opf.common_models.cluster_params import (
  getScalarMetricWithTimeOfDayAnomalyParams)
try:
  from nupic.frameworks.opf.model_factory import ModelFactory
except:
  # Try importing it the old way (version < 0.7.0.dev0)
  from nupic.frameworks.opf.modelfactory import ModelFactory

from nab.detectors.numenta.numenta_detector import NumentaDetector

(NumentaTM_detector.py)

from nupic.algorithms import anomaly_likelihood
from nupic.frameworks.opf.common_models.cluster_params import (
  getScalarMetricWithTimeOfDayAnomalyParams)
try:
  from nupic.frameworks.opf.model_factory import ModelFactory
except:
  # Try importing it the old way (version < 0.7.0.dev0)
  from nupic.frameworks.opf.modelfactory import ModelFactory

(Numenta_detector.py)

Thanks a lot!

1 Like
#2

NAB does not include a detector for the community fork of nupic. We are updating it to run scoring in python 3, but no plans of adding the fork as a NAB detector.

1 Like
#3

Sure thing. But I suppose you did not get what I asked. Maybe I haven’t expressed it clearly.

I am planning to rewrite NAB with Python 3.6 myself, maybe excluding some detectors. But I do have plans for Numenta_detector and NumentaTM_detector.

I am not certain about the current progress of the community version, and more specifically about whether the current community version provides the functionality that is required in implementing the two detectors, such as algorithms, Python interfaces, etc.

I am wondering if you could take a glance at the import lines I attached and kindly tell me whether they are supported.

If some revelant interfaces have been changed, I will be really grateful if you could refer me to the corresponding materials, like the new interface/class names in the new API docs.

p.s. If the community is going to rewrite NAB in Python 3.x in the future, I will be happy to contribute.

1 Like
#4

Please wait, because we (Numenta) are doing this ourselves as I first mentioned here. I’m afraid it will be wasted work.

And no, I can tell you that those import lines are not supported in the community fork.

1 Like
#5

Thx for your reply.

I’m sorry I missed the topic you linked. May I ask is there a specific schedule for NAB in Python 3.x?

I am currently researching time series anomaly detectiom for my thesis and find HTM intriguing. The work of NAB is also inspiring and helpful. I’m trying to adopt them as part of the baselines and evaluation metrics. For this reason, I have a strict schedule and deadline.

I will test the HTM based detector with Python 2.7. Given that the rest of my code for experiments are all based on Python 3.6, I may have to rewrite NAB, excluding the existing detectors, myself, even if it will be wasted work.

Just by the way, if the structure and interfaces of official NAB in Python 3.x remain the same and coding hasn’t started, I am happy to save you some trivial work in the process.

2 Likes
#6

Hi WMBao,

I too would like to see NAB in Python3. The bad news is that Numenta moves at their own pace and anyone who still uses python2 is probably going to keep using it until it dies in 2020. The good news is that NAB is open source so we can take matters into our own hands.

I’ve taken the liberty of forking NAB into the HTM-Community github account, of which I’m a member. My hope with this new repository is to make a python3 version of NAB which runs the community-fork version of nupic. So far I’ve converted all of it to python3, except for the HTM detectors.

If you’re interested in working on this together then I can give you write access to it. I can assure you that other people are interested in this and that the work will not be wasted.

1 Like
#7

We are moving pretty fast on this. I’ll live stream about it tomorrow.

1 Like
#8

Here is what we are planning (in two parts because I had a meeting):

Will the deprecated OPF be replaced?
#9

There is an easy way to convert python2 code to python3. All python3 installations should come packaged with a program called “2to3” or “py2to3” which will automatically convert to the new syntax.

I ran the 2to3 program on NAB and pushed the results to the community fork.

  • I tested that the following detectors yield similar scores to what the README says that they should score: null, random, bayesChangePt, windowedGaussian, expose, relativeEntropy, earthgeckoSkyline
  • I did not test the following detectors: Etsy Skyline, Twitter ADVec v1.0.0, Random Cut Forest, KNN CAD, CAD OSE, NumentaTM, Numenta HTM
  • The numenta detectors are unimplemented in python3 because Nupic does not support python3.

All of the detectors other than the numenta detector should be easy to port to python3.

1 Like