Using findParameters instead of swarming

#1

I’ve tried adapting the hotgym anomaly detection code to use findParameters instead of loading the swarmed model but I’ve run into the following issue:

The solution seems to be a conversion between those 2 types but I can’t find any documentation/example on how to achieve that.

#2

I wonder if you are passing the timestamp properly, is it a datetime object?

#3

I’m passing the result of datetime.datetime.strptime(row[0], "%Y-%m-%d %H:%M:%S.%f")

#4

This seems related:

If you pass it a hard-coded date like datetime(2011, 1, 2) does it still fail with the same error?

#5

I’ve used:

samples = (datetime(2011, 1, 2), 1.0)
params = findParameters(samples)

and it throws error:

Traceback (most recent call last):
File "/snap/pycharm-community/123/helpers/pydev/pydevd.py", line 1741, in <module>
    main()
File "/snap/pycharm-community/123/helpers/pydev/pydevd.py", line 1735, in main
    globals = debugger.run(setup['file'], None, None, is_module)
File "/snap/pycharm-community/123/helpers/pydev/pydevd.py", line 1135, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
File "/home/neo/Projects/nupic/examples/opf/clients/hotgym/anomaly/one_gym/run.py", line 210, in <module>
    runModel(GYM_NAME, plot=plot)
File "/home/neo/Projects/nupic/examples/opf/clients/hotgym/anomaly/one_gym/run.py", line 199, in runModel
    model = createModel(inputData)
File "/home/neo/Projects/nupic/examples/opf/clients/hotgym/anomaly/one_gym/run.py", line 83, in createModel
    samples = (datetime(2011, 1, 2), 1.0)
TypeError: 'module' object is not callable
#6

Ah, I needed to use datetime.datetime:

samples = [(datetime.datetime(2011, 1, 2), 1.0)]
params = findParameters(samples)

And it works this way.

#7

But then the question is how to get datetime.datetime.strptime(row[0], DATE_FORMAT) to have the same type as datetime.datetime(2011, 1, 2).

#8

Python is telling me that both of them are of type datetime.datetime so I don’t get why one would work and the other wouldn’t.