In [1]:
from nupic.encoders.category import CategoryEncoder, UNKNOWN

In [2]:
categories = ["ES", "GB", "US"]

In [3]:
e = CategoryEncoder(w=3, categoryList=categories, forced=True)

In [4]:
for category in categories: print(e.encode(category))


[0 0 0 1 1 1 0 0 0 0 0 0]
[0 0 0 0 0 0 1 1 1 0 0 0]
[0 0 0 0 0 0 0 0 0 1 1 1]

In [5]:
print(e.decode(e.encode("GB")))


({'category': ([(2, 2)], 'GB')}, ['category'])

In [6]:
print(e.decode(e.encode("ES")))


({'category': ([(1, 1)], 'ES')}, ['category'])

In [ ]: