我需要在聚类后应用分类器算法。现在在聚类之后,我找到了哪个 id 属于哪个集群的 id 号。我将它们聚集成 2 个集群。
现在我需要使用那些 id 来收集这些数据。但我不知道如何使用这些 id 收集所有信息。
当我使用 jupyeter notebook 并且在主数据中,当我从主数据文件加载数据时,我没有名为 id 的属性,并且那些 id 分配给 jupyter notebook。
这是我的主要数据
这是我查找哪些数据属于哪个集群的代码。
x = 0.10
i=0
C_i = np.where(labels == i)[0].tolist()
n_i = len(C_i) # number of points in cluster i
# (2) indices of the points from X to be sampled from cluster i
sample_i = np.random.choice(C_i, int(x * n_i))
print (i, sample_i)
聚类后我找到了这些 id
新增内容:
假设我的加载文件名是 train. 现在使用train.loc[26]命令我得到该特定 ID 的信息。
但我需要将所有信息收集到一个新的数据框中,比如数据train框




