brandonckelly / bck_stats

Routines for implementing various statistical and machine learning techniques.
MIT License
19 stars 5 forks source link

Error in DBA implementation #1

Open deltaoui opened 6 years ago

deltaoui commented 6 years ago

Hello, I've installed the package and I am facing an error while executing a dba function "compute_average". This is my code:

df = pd.read_csv("test.csv")
dba_ = dba.DBA(max_iter=10,verbose=True)
dba_.compute_average(tseries=df.values)

The error I am getting is this:

lib/python2.7/site-packages/bck_stats/dba.pyc in _dba_iteration(self, tseries)
    233         wgss = 0.0  # within group sum of squares from previous iteration, compute here so we don't have to repeat
    234         for series in tseries:
--> 235             if self.average.shape[1] == 1:
    236                 series = series[:, np.newaxis]
    237             dtw_dist, dtw, path = dynamic_time_warping(self.average, series)

IndexError: tuple index out of range

When I look at the code I see that self.average = np.zeros(1) and is not two dimensional, so I don't understand why are we testing its shape[1]... you'll get the same error if you do this :

print(np.zeros(1).shape[1])

brandonckelly commented 6 years ago

It looks like you are not feeding dba.compute_average() a list of numpy arrays, which it expects. Can you try reshaping your input into a list of arrays and try again?

flobeck commented 6 years ago

Hi guys, the following code throws the same error as above:

dba_ = dba.DBA(max_iter=10, verbose=True)
tseries = [np.random.rand(10) for i in range(0,5)]  # list of numpy arrays
dba_.compute_average(tseries)