1

I have a dateset with samples of different length. Therefore I decided to store each sample as numpy array in a list like this:

import numpy as np
a = list()
b = np.array([1,4,5])
c = np.array([4,3,9,7])
d = np.array([1,9,8])
a.append(b)
a.append(c)
a.append(b)

Now I want to calculate features for each sample, for example the mean. What is the most elegant way to do this? Does is make sense at all, to store the samples in a list? Currently I would proceed like this:

e = np.array([])
for i in range(len(a)):
    e = np.append(e, np.mean(a[i]))

But this seems to be very slow. I have the feeling there is a much easier solution. How would you handle samples of different length for feature calculation

Jonas Jo
  • 25
  • 4

0 Answers0