def cluster_guess_for_each_obs(self):
flat_cluster_guess = [self.argmax_list(cp) for cp in self.cluster_possibilities_for_observations()]
zero_cluster = [0.0 for i in self.clusters]
all_zero_clusters = [zero_cluster for p in range(len(flat_cluster_guess))]
for enum in enumerate(flat_cluster_guess):
all_zero_clusters[enum[0]][enum[1]] = 1.0
print all_zero_clusters
self.cluster_assignments = all_zero_cluster
return
现在第一行返回一个 0 和 1 的列表,表示每个数据属于哪个集群。我想将它(例如 [0, 1, 0, 0, 1, 1, 1])转换为长度为 2 的数组的数组,如下所示: [[1, 0], [0 , 1], [1, 0], [1, 0], [0, 1], [0, 1], [0, 1]]。相反,我得到的是在前几次枚举之后它全是 1。
不知道我做错了什么。