NuPIC over HTTP?


I’m looking for the best way to connect nupic to REST stream and procced with predictions in real time?
Here is the scenario : the network will calculate the records one by one coming through rest API and waiting for the next record, keeping connectivity even if no data is arriving for some time.
I didn’t find the correct stream class for it. It seems that the system is working only for reading csv files or to generate data trhough a loop.
Is it possibly to do with nupic ?

Thanks for your help :slight_smile:

1 Like

HITC (HTM In the Cloud) is an example of a really simple HTTP server that runs NuPIC:

@Jonathan_Mackenzie and I created this for a project a couple years ago. It works with NuPIC 1.5.6. It won’t work with the latest NuPIC (probably?), but it is an example of doing exactly what you are asking.

Thanks, for you suggestion :slight_smile:

It seems that again in this example ‘CLA’ model is used that is easy to run and feed with incoming data.
I’m trying to make it work with network, and I’m stucked in the point that it seems that to feed a network I can only do it through a csv file (nupic v1.0.3):

dataSource = FileRecordStream(streamID=_INPUT_FILE_PATH)
# Specify the dataSource as a file record stream instance
sensor.dataSource = dataSource`

I thought that “StreamReader” class might be a solution, but still it seems that model description accepts only csv file as a source of data, in my case I want it to accept only a pair of values {timestamp, value}, coming from HTTP REST.

  'streams': [
      {'columns': [u'*'],
       'info': u'hotGym.csv',
       'last_record': 4000,
       'source': u'file://extra/hotgym/hotgym.csv'}. => here only file can be indicated :(

Maybe there is another way to feed “sensor” with data that is not coming from csv?

thanks :slight_smile:

I think you’ll need to implement the RecordStream interface yourself. @mrcslws or @scott do you have any clues?

@rhyolight - correct that you could implement your own RecordStream subclass in order to still use the OPF. It might be easier to not use the OPF though. The docs cover the alternative interfaces:

Scott, I don’t think he’s using the OPF. He’s needs to create a sensor region that is not a FileRecordSensor as described in the doc example. So he’ll still need to implement RecordStream as far as I can tell.

In fact, I’m trying to implement your latest approach (on my data using HTTP REST):
HTM > Prediction Error > Anomaly Likelihood

publihshed in Unsupervised real-time anomaly detection for streaming data

As I could uderstand it was realised with Network interface. But if it can be also also achieved with other nupic interfaces, can you please recommend which one will suite better my need ?

If you’re just looking for anomaly likelihood, you can probably just use HITC as-is. It returns an anomaly score and likelihood value by default. There is an example of usage here:


Thanks a lot :wink: I’ll try it and will share my results:)