# Nupic API for multi field Input

**URL:** <https://discourse.numenta.org/t/nupic-api-for-multi-field-input/1831>\
**Category:** NuPIC\
**Tags:** numenta\
**Created:** [January 25, 2017, 2:11pm UTC](https://discourse.numenta.org/t/nupic-api-for-multi-field-input/1831 "2017-01-25T14:11:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikash0837](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@vikash0837](https://discourse.numenta.org/u/vikash0837)\
**Post date:** [January 25, 2017, 2:11pm UTC](https://discourse.numenta.org/t/nupic-api-for-multi-field-input/1831/1 "2017-01-25T14:11:33Z")

</div>

Hi,  
I have gone through the examples available in nupic-master but all are based on single variable as an INPUT FIELD . Is there any example using NUPIC which accepts more than on input field and predicts the output and detects the anomaly.

* * *

Thanks  
Vikash

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [January 25, 2017, 3:39pm UTC](https://discourse.numenta.org/t/nupic-api-for-multi-field-input/1831/2 "2017-01-25T15:39:11Z")

</div>

Here’s an example project I created that uses multiple input fields, but I’m afraid it might not work because it depend on River View (and [River View is not healthy](https://discourse.numenta.org/t/river-view-problems/1778)). But the code might be useful to give you an example of how to put together a model with many inputs.

> **[htm-community/menorah](https://github.com/htm-community/menorah)**
>
> Menorah is a NuPIC experiment framework for River View. - htm-community/menorah

---

<div class="post-metadata">

**Author:** ![vikash0837](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@vikash0837](https://discourse.numenta.org/u/vikash0837)\
**Post date:** [January 26, 2017, 5:40pm UTC](https://discourse.numenta.org/t/nupic-api-for-multi-field-input/1831/3 "2017-01-26T17:40:11Z")

</div>

Thanks @rhyolight🙂

---

<div class="post-metadata">

**Author:** ![vikash0837](https://avatars.discourse-cdn.com/v4/letter/v/8dc957/32.png) [@vikash0837](https://discourse.numenta.org/u/vikash0837)\
**Post date:** [February 2, 2017, 12:07pm UTC](https://discourse.numenta.org/t/nupic-api-for-multi-field-input/1831/4 "2017-02-02T12:07:47Z")

</div>

Hi Matt,  
I was trying to run the Menorah locally.i tried [exmple1.py](http://exmple1.py) but i got the error that “No JSON object could be decoded”. I went through the code but i couldn’t understand that how you are getting the streaming data for the input. Please help me out to resolve the issue.  
Thanks in anticipation.

* * *

Regards  
Vikash0837

---

<div class="post-metadata">

**Author:** ![rhyolight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/rhyolight/32/3922_2.png) [@rhyolight](https://discourse.numenta.org/u/rhyolight)\
**Post date:** [February 2, 2017, 8:36pm UTC](https://discourse.numenta.org/t/nupic-api-for-multi-field-input/1831/5 "2017-02-02T20:36:32Z")

</div>

Honestly, we don’t have a good example of swarming and running models on multiple fields (if someone knows one, please share). Menorah was more of a proof of concept (experiment) than a tutorial.

> [@vikash0837](#):
>
> I was trying to run the Menorah locally.i tried exmple1.py but i got the error that “No JSON object could be decoded”.

Are you connected to the internet when you run? Menorah pulls data from [http://data.numenta.org](http://data.numenta.org).

You can try adding `debug=True` to the `Menorah` constructor call here in the example code here:

> <https://github.com/htm-community/menorah/blob/master/examples/example1.py#L13>

That should print out the URLs that Menorah is fetching data from. You should be able to hit those URLs in your web browser and see JSON data.

When Menorah runs, it should create a working directory with the swarm definition in it. If you see that, please share it.

---

<div class="post-metadata">

**Author:** ![mellertson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.numenta.org/mellertson/32/653_2.png) [@mellertson](https://discourse.numenta.org/u/mellertson)\
**Post date:** [February 3, 2017, 2:14am UTC](https://discourse.numenta.org/t/nupic-api-for-multi-field-input/1831/6 "2017-02-03T02:14:32Z")

</div>

I extracted this code from a predictive application I put together. It predicts 5 time steps ahead and needs a CSV file placed in /tmp/input.csv before it runs. I needed it to be flexible enough to handle any number of input data columns. I’ve tested it and it seems to work well enough. Although, I’d love to get feedback on it from other forum members to learn if there are ways to improve its predictive capabilities.

After swarming over your data to build a model, it loops over the ‘input.csv’ data and feeds them to the model’s run() method. This code doesn’t use the predictions form time-steps 2-5, I omitted the code that calculates statistics on the other time-step predictions, for sake of brevity.

There might be a few errors in the code below, I copied and pasted it in from a larger program. But, I hope it’ll be enough to get your started.

> <https://gist.github.com/mellertson/0f9f1c4989c4a92832391515b6df53ac>
