Using findParameters instead of swarming


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.


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


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


This seems related:

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


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/", line 1741, in <module>
File "/snap/pycharm-community/123/helpers/pydev/", line 1735, in main
    globals =['file'], None, None, is_module)
File "/snap/pycharm-community/123/helpers/pydev/", 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/", line 210, in <module>
    runModel(GYM_NAME, plot=plot)
File "/home/neo/Projects/nupic/examples/opf/clients/hotgym/anomaly/one_gym/", line 199, in runModel
    model = createModel(inputData)
File "/home/neo/Projects/nupic/examples/opf/clients/hotgym/anomaly/one_gym/", line 83, in createModel
    samples = (datetime(2011, 1, 2), 1.0)
TypeError: 'module' object is not callable

Ah, I needed to use datetime.datetime:

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

And it works this way.


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).


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.