Nupic_output updated file

Hi everyone; I am using nupic with python on my custom anomaly detection, Now I am facing issue with using nupic_output.py file ploting and file writting…
I used nupic_output.py from oneHotGym example as well as sine_prediction example…
Thanx in advance for your help…

what kind of issue is ?

1 Like

That file for the example depends on matplotlib being installed properly on your computer. Sometimes you need to figure what to do in your environment to properly install / run matplotlib.

Thanx @rhyolight
I would like to ask more specific…
so would you like to spacify the matplotlib version with a generic nupic_output.py file… That works for all sort of examples to wheather write to a file or plot… and mention a link to nupic_output.py
Thanx @rhyolight for your time…

Thnx @way-sal the error is something like this… while it is working with writing to a file

This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called before pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

The backend was originally set to ‘module://backend_interagg’ by the following code:
File “/home/wanclouds/PycharmProjects/HTM_real_data_anomaly/run.py”, line 3, in
import matplotlib.backends
File “/home/wanclouds/sine_prediction/venv/local/lib/python2.7/site-packages/matplotlib/backends/init.py”, line 16, in
line for line in traceback.format_stack()

matplotlib.use(‘TKAgg’)
/home/wanclouds/PycharmProjects/HTM_real_data_anomaly/nupic_output.py:34: UserWarning:
This call to matplotlib.use() has no effect because the backend has already
been chosen; matplotlib.use() must be called before pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

The backend was originally set to ‘module://backend_interagg’ by the following code:
File “/home/wanclouds/PycharmProjects/HTM_real_data_anomaly/run.py”, line 3, in
import matplotlib.backends
File “/home/wanclouds/sine_prediction/venv/local/lib/python2.7/site-packages/matplotlib/backends/init.py”, line 16, in
line for line in traceback.format_stack()

matplotlib.use(‘TKAgg’)
Traceback (most recent call last):
File “/home/wanclouds/PycharmProjects/HTM_real_data_anomaly/run.py”, line 114, in
run()
File “/home/wanclouds/PycharmProjects/HTM_real_data_anomaly/run.py”, line 110, in run
run_model(model)
File “/home/wanclouds/PycharmProjects/HTM_real_data_anomaly/run.py”, line 70, in run_model
output.write([timestamp], [packets], [prediction])
File “/home/wanclouds/PycharmProjects/HTM_real_data_anomaly/nupic_output.py”, line 155, in write
self.initializeLines(timestamps)
File “/home/wanclouds/PycharmProjects/HTM_real_data_anomaly/nupic_output.py”, line 132, in initializeLines
[date2num(date) for date in self.dates[index]], maxlen=WINDOW
File “/home/wanclouds/sine_prediction/venv/local/lib/python2.7/site-packages/matplotlib/dates.py”, line 452, in date2num
return _to_ordinalf_np_vectorized(d)
File “/home/wanclouds/.local/lib/python2.7/site-packages/numpy/lib/function_base.py”, line 2576, in call
return self._vectorize_call(func=func, args=vargs)
File “/home/wanclouds/.local/lib/python2.7/site-packages/numpy/lib/function_base.py”, line 2646, in _vectorize_call
ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
File “/home/wanclouds/.local/lib/python2.7/site-packages/numpy/lib/function_base.py”, line 2606, in _get_ufunc_and_otypes
outputs = func(*inputs)
File “/home/wanclouds/sine_prediction/venv/local/lib/python2.7/site-packages/matplotlib/dates.py”, line 255, in to_ordinalf
base = float(dt.toordinal())
AttributeError: 'numpy.string
’ object has no attribute ‘toordinal’

I’m using matplotlib 2.1.0. Sorry I can’t help you out more. If you can’t get matplotlib working, you can use the write to file option and plot the results in another way manually.

Thnx @rhyolight alot for your time.

Hey, I recommend running it outside your python virtual environment and see if it makes any difference. Are you running on OSX?