[英]How can I know which cluster of self-organizing map (SOM) an element belongs to in python?
I am new with clustering and neural nets, and I have just started using Self-Organizing Maps (SOM) to perform some clustering.我是聚类和神经网络的新手,我刚刚开始使用自组织映射 (SOM) 来执行一些聚类。 I have a 15 dimensional dataset and I created a som with the next code:我有一个 15 维数据集,我用下一个代码创建了一个 som:
size = 20
from minisom import MiniSom
som = MiniSom(size, size, 15, sigma=0.3, learning_rate=0.9, random_seed=149)
som.train_random(data, 650000, verbose=True)
And I plotted the som the next way:我以下一种方式绘制了 som:
plt.figure()
plt.pcolor(som.distance_map().T, cmap='Blues')
plt.colorbar()
plt.show()
My question is: if I have a new 15 dimensional element, how can I know which cluster of the som belongs to?我的问题是:如果我有一个新的 15 维元素,我怎么知道 som 属于哪个簇?
Best Matching Unit (BMU)最佳匹配单元 (BMU)
for t in itertools.count():
i = np.random.choice(range(len(data)))
bmu = self.find_bmu(data[i])
Finding the Best Matching Unit寻找最佳匹配单元
create nxn map with random node vector values使用随机节点向量值创建 nxn 映射
loop while s < StepsMax times循环而 s < StepsMax 次数
compute what a "close" node means, based on s根据 s 计算“关闭”节点的含义
compute a learn rate, based on s计算学习率,基于 s
pick a random data item选择一个随机数据项
determine the map node closest to data item (BMU)确定最接近数据项(BMU)的地图节点
for-each node close to the BMU对于靠近 BMU 的每个节点
adjust node vector values towards data item向数据项调整节点向量值
end-loop结束循环
I have a feeling that MiniSom has a function implemented for this:我有一种感觉,MiniSom 为此实现了一个功能:
som.winner(*input_data*)
which returns the node that it is closest to.它返回它最接近的节点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.