需要自组织映射中 U 矩阵的具体示例
我正在尝试开发一个使用 SOM 来分析数据的应用程序。但是,完成训练后,我找不到可视化结果的方法。我知道U-Matrix是其中一种方法,但我无法正确理解它。因此,我要求提供一个如何构建 U 矩阵的具体且详细的示例。
我还在 U 矩阵和自组织映射 上阅读了答案,但它只是指的是1行地图,3x3地图怎么样?我知道对于 3x3 地图:
m(1) m(2) m(3)
m(4) m(5) m(6)
m(7) m(8) m(9)
必须创建 5x5 矩阵:
u(1) u(1,2) u(2) u(2,3) u(3)
u(1,4) u(1,2,4,5) u(2,5) u(2,3,5,6) u(3,6)
u(4) u(4,5) u(5) u(5,6) u(6)
u(4,7) u(4,5,7,8) u(5,8) u(5,6,8,9) u(6,9)
u(7) u(7,8) u(8) u(8,9) u(9)
但我不知道如何计算 u 权重 u(1,2,4,5), u(2,3,5,6), u( 4,5,7,8) 和 u(5,6,8,9)。
最后,在构建了U-Matrix之后,有没有办法使用颜色来可视化它,例如热图?
非常感谢您抽出时间。
干杯
I'm trying to develop an application using SOM in analyzing data. However, after finishing training, I cannot find a way to visualize the result. I know that U-Matrix is one of the method but I cannot understand it properly. Hence, I'm asking for a specific and detail example how to construct U-Matrix.
I also read an answer at U-matrix and self organizing maps but it only refers to 1 row map, how about 3x3 map? I know that for 3x3 map:
m(1) m(2) m(3)
m(4) m(5) m(6)
m(7) m(8) m(9)
a 5x5 matrix must me created:
u(1) u(1,2) u(2) u(2,3) u(3)
u(1,4) u(1,2,4,5) u(2,5) u(2,3,5,6) u(3,6)
u(4) u(4,5) u(5) u(5,6) u(6)
u(4,7) u(4,5,7,8) u(5,8) u(5,6,8,9) u(6,9)
u(7) u(7,8) u(8) u(8,9) u(9)
but I don't know how to calculate u-weight u(1,2,4,5), u(2,3,5,6), u(4,5,7,8) and u(5,6,8,9).
Finally, after constructing U-Matrix, is there any way to visualize it using color, e.g. heat map?
Thank you very much for your time.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道你是否仍然对此感兴趣,但我找到了这个链接
http://www.uni-marburg.de/fb12/datenbionik /pdf/pubs/1990/UltschSiemon90
它非常具体地解释了如何计算 U 矩阵。
希望有帮助。
顺便说一句,我发现该网站的链接有几个涉及 SOM 的资源,我将其留在这里以防有人感兴趣:
http://www.ifs.tuwien.ac.at/dm/somtoolbox /可视化.html
I don't know if you are still interested in this but I found this link
http://www.uni-marburg.de/fb12/datenbionik/pdf/pubs/1990/UltschSiemon90
which explains very speciffically how to calculate the U-matrix.
Hope it helps.
By the way, the site were I found the link has several resources referring to SOMs I leave it here in case anyone is interested:
http://www.ifs.tuwien.ac.at/dm/somtoolbox/visualisations.html
Kohonen 地图的基本思想是将数据点映射到
晶格,通常是二维矩形网格。
在最简单的实现中,晶格通过创建 3D 来初始化
具有以下尺寸的数组:
这是 U 矩阵。
宽度和高度由用户选择; number_features 只是数字
数据中的特征(列或字段)。
直观上,这只是创建一个尺寸为 w * h 的 2D 网格
(例如,如果 w = 10 且 h = 10,则您的晶格有 100 个单元格),那么
到每个单元格中,放置一个随机的一维数组(有时称为“参考元组”)
其大小和值受您的数据限制。
参考元组也称为权重。
U 矩阵是如何渲染的?
在下面的示例中,数据由 RGB 元组组成,所以参考元组
长度为 3,并且这三个值中的每一个都必须位于 0 到 255 之间)。
您可以通过这个 3D 数组(“晶格”)开始主迭代循环
该算法迭代地定位每个数据点,使其最接近其他相似的数据点。
如果您随时间(迭代次数)绘制它,那么您可以可视化集群
形成。
我为此使用的绘图工具是出色的 Python 库 Matplotlib,
它直接绘制晶格,只需将其传递到 imshow 函数。
下面是 SOM 算法进度的八个快照,从初始化到 700 次迭代。新初始化的(iteration_count = 0)晶格渲染在左上方面板中;最终迭代的结果位于右下面板中。
或者,您可以使用较低级别的成像库(Python 中的,例如 PIL)并将参考元组一次一个地传输到 2D 网格上:
这里 img 是 PIL 的 的一个实例>图像类。这里的图像是通过一次一个像素迭代网格来创建的;对于每个像素,putpixel 会在 img 上调用三次,这三次调用当然对应于 RGB 元组中的三个值。
The essential idea of a Kohonen map is that the data points are mapped to a
lattice, which is often a 2D rectangular grid.
In the simplest implementations, the lattice is initialized by creating a 3D
array with these dimensions:
This is the U-matrix.
Width and height are chosen by the user; number_features is just the number
of features (columns or fields) in your data.
Intuitively this is just creating a 2D grid of dimensions w * h
(e.g., if w = 10 and h = 10 then your lattice has 100 cells), then
into each cell, placing a random 1D array (sometimes called "reference tuples")
whose size and values are constrained by your data.
The reference tuples are also referred to as weights.
How is the U-matrix rendered?
In my example below, the data is comprised of rgb tuples, so the reference tuples
have length of three and each of the three values must lie between 0 and 255).
It's with this 3D array ("lattice") that you begin the main iterative loop
The algorithm iteratively positions each data point so that it is closest to others similar to it.
If you plot it over time (iteration number) then you can visualize cluster
formation.
The plotting tool i use for this is the brilliant Python library, Matplotlib,
which plots the lattice directly, just by passing it into the imshow function.
Below are eight snapshots of the progress of a SOM algorithm, from initialization to 700 iterations. The newly initialized (iteration_count = 0) lattice is rendered in the top left panel; the result from the final iteration, in the bottom right panel.
Alternatively, you can use a lower-level imaging library (in Python, e.g., PIL) and transfer the reference tuples onto the 2D grid, one at a time:
Here img is an instance of PIL's Image class. Here the image is created by iterating over the grid one pixel at a time; for each pixel, putpixel is called on img three times, the three calls of course corresponding to the three values in an rgb tuple.
从您创建的矩阵中:
具有单个数字的元素,如 u(1)、u(2)、...、u(9) 以及具有两个以上数字的元素,如 u(1,2,4,5) ), u(2,3,5,6), ... , u(5,6,8,9) 使用邻域值的平均值、中值、最小值或最大值等计算。
首先用两个数字计算元素是一个好主意,一个可能的代码是:
在
self.h_u_matrix = self.weights.shape[0]*2 - 1
和上面的代码中>self.w_u_matrix = self.weights.shape[1]*2 - 1
是 U 矩阵的维度。话虽如此,为了计算其他元素,有必要获取它们邻居的列表并应用平均值。下面的代码实现了这个想法:From the matrix that you create:
The elements with single numbers like u(1), u(2), ..., u(9) as just the elements with more than two numbers like u(1,2,4,5), u(2,3,5,6), ... , u(5,6,8,9) are calculated using something like the mean, median, min or max of the values in the neighborhood.
It's a nice idea calculate the elements with two numbers first, one possible code for that is:
In the code above the
self.h_u_matrix = self.weights.shape[0]*2 - 1
andself.w_u_matrix = self.weights.shape[1]*2 - 1
are the dimensions of the U-Matrix. With that said, for calculate the others elements it's necessary obtain a list with they neighboors and apply a mean for example. The following code implements that's idea: