Solved – Performing a Self-Organizing Map on multiple distance matrices in R with a better visualization

data visualizationmatrixrself organizing maps

I have a number of distance matrices that are related to different elements. Each of these matrices represent a specific distance between these elements. I want to perform a Self-Organizing Map technique on them in R and get a Heatmap or something that could present the data well. But the SOM function does not create something that is easily interpretable. I made a sample matrix of 1000*1000 and the SOM function of kohonen library gave me this: (which I am not sure what does it mean)
a busy cat
The code that I used for R is:

test.som <- som( data = mat , grid = somgrid(3,3,"hexagonal"))

and then I plotted the test.som. My question is how do I include more that one distance matrix in the SOM function and is there a better visualization for this data?
P.S.
The distance matrices are not Euclidean matrices, they should be calculated one by one.

Best Answer

The result is not stupid. You asked SOM to work with continuous variables (distances) and there are lots of them (1000 vars). The line traces are the "spectra"; which, in this case, means the position on the horizontal axis indicates the "variable" (in your case each column of the distance matrix) and the height in y indicates the importance of those "variables" for each of the prototypes that represents each grid in your SOM.

What you are doing doesn't make much sense, at least for som(). It should be provided with the raw data that you used to generate the distance matrix.

I suppose there could be some use for this - what the plotted results are trying to show you graphically is that the upper-left cell contains those observations that are very dissimilar to the first few observations (rows) in the matrix.

I'm not convinced it is useful however. I would have proceeded, if using SOM, by providing the raw data.

If you just want a heatmap, try

heatmap(mat)