scipy で kmeans クラスタリングを使用しようとしています。まさにここに存在するものです。
私がやろうとしているのは、次のようなリストのリストを変換することです:
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]
]
Kmeans メソッドで使用するために ndarry に変換します。list のリストを ndarray に変換しようとすると、空の配列が得られるため、分析全体が無効になります。ndarray の長さは可変で、収集されたサンプルの数によって異なります。しかし、len(data_without_x) で簡単に取得できます
空のリストを返すコードのスニペットを次に示します。
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)
これは、単純なログファイルに保存するだけで出力として得られるものです。
___________________________
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]]
___________________________
リストのリストを numpy.array に変換しようとするとどうなるか、誰にも手掛かりがありますか?
ご協力いただきありがとうございます