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.

This error statement TypeError: ‘module’ object is not callable is raised as you are being confused about the Class name and Module name. The problem is in the import line . You are importing a module, not a class. This happend because the module name and class name have the same name .

If you have a class “MyClass” in a file called “” , then you should import :

from MyClass import MyClass

In Python , a script is a module, whose name is determined by the filename . So when you start out your file with import MyClass you are creating a loop in the module structure.

In Python, everything (including functions, methods, modules, classes etc.) is an object , and methods are just attributes like every others. So,there’s no separate namespaces for methods. So when you set an instance attribute, it shadows the class attribute by the same name. The obvious solution is to give attributes different names.