Example usage of Coordinate Encoder

I’m puzzled by this discussion
I’m using nupic 1.0 and it appears that method _neighbors(coordinate, radius) is not implemented appropriately as it only operates on one axis.
I am also modifying the file coordinate.py in order to sort out inconsistencies with data types apparently required (dict,tuple or numpy array)
Have I missed something?

The _neighbors() code seems to work on N-dimensions of the coordinate to me, so I’m not sure what you mean:

ranges = (xrange(n-radius, n+radius+1) for n in coordinate.tolist())
return numpy.array(list(itertools.product(*ranges)))

Are you talking about this?

@param inputData (tuple) Contains coordinate (numpy.array, N-dimensional
                         integer coordinate) and radius (int)

So you need to pass something like this:

coords = [1,2,3,4,5]
radius = 4
coordinateEncoder.encodeIntoArray((coords, radius,))

Is this what is causing you trouble?

Ok, so my nupic version is: 0.5.5
nupic bindings version: 0.4.5

Do you think this could be the source of the problem?

Thanks again :slight_smile:

That version looks like the correct one. I’m not sure why there is a problem. I do suggest you install NuPIC at the latest version, but you’ll need to update your code for the breaking changes. There shouldn’t be that much to do in order to update.

I assume that’s the most reliable way to solve this and I should do it anyway. Would you recommend uninstalling my current nupic and nupic bindings first? If you’ve already done a walk through of that would you direct me to it? Thanks again!


Thank you for your prompt and helpful reply. - However
This works:

  inputData = { 'coordinate':[17,37], 'radius':4 }
  base = encoder.encode( inputData )
  print( base )

But this does not work!

  coords = [1,2,3,4,5]
  radius = 4
  base2 = encoder.encodeIntoArray((coords, radius,))
  TypeError: encodeIntoArray() takes exactly 3 arguments (2 given)

I think the problem may lie with my limited understanding of the use of python classes

Also on the topic of the coordinate encoder - Can you point me to any literature on plusses and minuses of different algorithms for encoding neighbors. I am aiming to experiment with anomaly detection in a sequence of coordinates where the sequence may be chaotic. The input is of the form [phi,rho] where both coordinate are in the range 0-2*pi.
I have a working modified coordinate.py which handle the wraparound.

Ok so I ran the uninstall commands for nupic and nupic bindings and got that message for both:

‘cannot uninstall requirement, not installed’

However when I then ran the command you showed me to check the version of nupic and nupic bindings, they still showed up as

nupic 0.5.5
nupic.bindings 0.4.5

Given this should I still just go ahead and

pip install nupic

to upgrade to 1.0?

Hmm when I try to run another nupic run file with a scalar encoder it still runs, so it seems like I haven’t uninstalled nupic then?

No it doesn’t seem like you have. Do you have virtual environments? Or more than one version of python?

I do have more than 1 version of python, yes. I switched the default do both python 2 and python 3 and ran the uninstall files, getting the ‘cannot uninstall requirements, not installed’ messages for both. I can try your other method, of:

rming the nupic.bindings-* files from your site-packages directory.

though I seem to have many site-package directories. Is there a certain file that would be in the right one that would help me pinpoint the right site-packages? I’m really sorry for this laborious hand-holding I’m making you do here :roll_eyes:

Find your site-packages folder(s) and search for any nupic.bindings files or directories. You may need to manually delete them.

Ok I found it! nupic.bindings is within site-packages/nupic/. Should I delete just the bindings folder or the whole nupic folder containing it?

Just delete the whole nupic folder and reinstall.

Ok its gone! I’ve never been so happy to see:

ImportError: No module named nupic

Lol. Now I’ll just simply

pip install nupic


Yep :crossed_fingers:

One stupid error in the way! In:

Collecting unittest2==0.5.1 (from nupic)

Any thoughts to get around this?


When I set my default python to python 3 it will import nupic but not nupic bindings, and when I set it to python 2 it wont do either. :thinking:

Hey @rhyolight, any ideas how I might probe next on this? I’ve been poking around without success so far. I’m sorry to pester you in this!

Definitely use python 2, not 3. And try uninstalling unittest2:

pip uninstall unittest2

8 posts were split to a new topic: Debugging CoordinateEncoder issues in NuPIC 1.0