ChristoferNal/power-disaggregation-complexity

Raised AttributeError while calling Clustering Algorithm

Opened this issue · 0 comments

Hello,

first of all, I want to thank you for publishing the source code! Glad to see that somebody investigated into complexity👍

While running some tests on REDD, I was confronted with the following problem in function statesCombinations :

    P = statesCombinations(meterlist)
  File "/Users/christoph/.../disaggregation_complexity.py", line 29, in statesCombinations
    states[i] = cluster(meter.power_series().next(), max_num_clusters=max_states)
AttributeError: 'generator' object has no attribute 'next'

Changing

meter.power_series().next()

to

next(meter.power_series())

resolved the issue for me. I am not quite sure whether or not this problem is related to my NILMTK installation. However, I added a try - catch statement and pushed it to my fork.

    for i, meter in enumerate(meterlist):
        try:
            states[i] = cluster(meter.power_series().next(), max_num_clusters=max_states)
        except AttributeError:
            states[i] = cluster(next(meter.power_series()), max_num_clusters=max_states)
    return np.sum(cartesian(states), axis=1)

Hopefully this will be useful for others.

Cheers,
Christoph