SOM 映射和集群树状图在 R 中不匹配?

问题描述

我在 R 中做 SOM 并且我做了 SOM 代码的聚类。我面临的问题是我需要从左上到下计数的 SOM 映射节点。但是在我的情况下,它从左下角开始,并且聚类树状图也与映射图相同?我该如何解决这个问题?给定的 SOM 映射图形节点和树状图不匹配。为什么节点数从底部开始?我需要它从左上角开始。

我使用的代码

library(som)


env.active1 <- env_table1[,2:19]

#scale data
iris.sc = scale(env_table1[,2:19])

head(iris.sc)
summary(iris.sc) 

library(kohonen)

#Choosing Grid
#iris.grid <- somgrid(xdim = 5,ydim=6,topo="hexagonal")  
#Build model
iris.som <- supersom(iris.sc,grid=iris.grid,rlen=1000,alpha=c(0.05,0.01),keep.data = TRUE)
summary(iris.som)
meanD <- mean(iris.som$distances) 


# Weight Vector View
plot(iris.som,type="codes")

plot(iris.som,type="mapping",border = "grey",shape = "straight")#The lower number of empty cells,the better SOM.

plot(iris.som,type="quality",shape = "straight") 

###

## Show the U matrix
Umat <- plot(iris.som,type="dist.neighbours",main = "SOM neighbour distances")



set.seed(123)
par(mfrow = c(1,1))
#cluster - WITH WARDS METHOD
df <- dist(iris.som$codes[[1]])
dd <- dist(df,method = "euclidean")

cah <- hclust(dd,method="ward.D2")
plot(cah,cex = 0.6,hang = -1)

#visualizing the  clusters into the dendrogram

plot(cah,cex = 0.6)
rect.hclust(cah,k = 4,border = 2:5)
groupes4 <- cutree(cah,k=4)

[enter image description here][1]


#highlight the clusters into the Kohonen map
plot(iris.som,bgcol=c("#01B4C6","#FEDF25","#00AF66FF","#F675DA")[groupes4],labels = env_table1$season)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...