I am trying to use kmeans clusters in scipy, exactly the one that is present here:
http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.vq.kmeans.html#scipy.cluster.vq.kmeans
I am trying to convert a list of a list, for example:
data without_x[ [0, 0, 0, 0, 0, 0, 0, 20.0, 1.0, 48.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1224.0, 125.5, 3156.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 22.5, 56.0, 41.5, 85.5, 0, 0, 0, 0, 0, 0, 0, 0, 1495.0, 3496.5, 2715.0, 5566.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ]
in ndarry to use it with the Kmeans method. When I try to convert the list of the list to ndarray, I get an empty array, thereby invalidating the whole analysis. The length of the ndarray is variable and depends on the number of samples collected. But I can easily figure it out with Len (data_without_x)
Here is a snippet of code that returns an empty list.
import numpy as np import "other functions" data, data_without_x = data_preparation.generate_sampled_pdf() nodes_stats, k, list_of_list= result_som.get_number_k() data_array = np.array(data_without_x) whitened = whiten(data_array) centroids, distortion = kmeans(whitened, int(k), iter=100000)
and this is what I get as output by simply storing in a simple log file:
___________________________ this is the data array[[ 0. 0. 0. ..., 0. 0. 0.] [ 0. 0. 0. ..., 0. 0. 0.] [ 0. 0. 0. ..., 0. 0. 0.] ..., [ 0. 0. 0. ..., 0. 0. 0.] [ 0. 0. 0. ..., 0. 0. 0.] [ 0. 0. 0. ..., 0. 0. 0.]] ___________________________ This is the whitened array[[ nan nan nan ..., nan nan nan] [ nan nan nan ..., nan nan nan] [ nan nan nan ..., nan nan nan] ..., [ nan nan nan ..., nan nan nan] [ nan nan nan ..., nan nan nan] [ nan nan nan ..., nan nan nan]] ___________________________
Does anyone know what happens when I try to convert a list of a list to numpy.array?
thanks for the help