[英]Error in supersom(list(X), ...) : argument "X" is missing, with no default in kohonen package som function
I am trying to apply the som function in the kohonen package (plot a SOM) and I am getting the following error:我正在尝试在 kohonen 包中应用 som 函数(绘制 SOM),但出现以下错误:
Error in supersom(list(X), ...) : argument "X" is missing, with no default. supersom(list(X), ...) 中的错误:缺少参数“X”,没有默认值。
The code that I am trying to apply is as follows:我尝试应用的代码如下:
... ...
load("somInput.rdata")
... ...
aGrid <- somgrid(xdim = 160, ydim = 100, topo="hexagonal")
data <- as.matrix(scale(na.omit(usa.bg.som[,1:7])))
aSom <- som(data=data, grid=aGrid, rlen=1, alpha=c(0.05, 0.01), keep.data=FALSE)
After the last line above I get the error.在上面的最后一行之后,我收到错误消息。
Can anyone resolve the error?任何人都可以解决错误吗? Help is revered.帮助是崇高的。
The full code:完整代码:
##CODE FOR BRUNDSON AND SINGLETON BOOK CHAPTER.
##LIBRARIES
library(kohonen)
##Code for Plots
source("somComponentPlanePlottingFunction.R")
#source("Map_COUNTY_BMU.R")
source("plotUMatrix.R")
#Load Data
##DATA FOR ALL BLOCKGROUPS IN THE US
##SOURCE ACS 2006-2010 AND CENSUS 2010
load("somInput.rdata")
#Build SOM
aGrid <- somgrid(xdim = 160, ydim = 100, topo="hexagonal")
##NEXT LINE IS SLOW!!!
##Rlen is arbitrarily low
data <- as.matrix(scale(na.omit(usa.bg.som[,1:7])))
aSom <- som(data=data, grid=aGrid, rlen=1, alpha=c(0.05, 0.01), keep.data=FALSE)
##VISUALIZE RESULTS
##COMPONENT PLANES
dev.off()
par(mar = rep(1, 4))
cplanelay <- layout(matrix(1:8, nrow=4))
vars <- colnames(aSom$data[[1]])
for(p in vars) {
plotCplane(som_obj=aSom, variable=p, legend=FALSE, type="Quantile")
}
plot(0, 0, type = "n", axes = FALSE, xlim=c(0, 1),
ylim=c(0, 1), xlab="", ylab= "")
par(mar = c(0, 0, 0, 6))
image.plot(legend.only=TRUE, col=rev(designer.colors(n=50, col=brewer.pal(9, "Spectral"))), zlim=c(-1.5,1.5))
##END PLOT
##PLOT U-MATRIX
dev.off()
plotUmat(aSom)
The full code can be retrieved from:可以从以下位置检索完整代码:
https://github.com/geoss/som_visualization_r/blob/master/Example.R https://github.com/geoss/som_visualization_r/blob/master/Example.R
Other needed files can be viewed and retrieved from:可以从以下位置查看和检索其他需要的文件:
https://github.com/geoss/som_visualization_r https://github.com/geoss/som_visualization_r
A question about how to plot hexagongrid in SOM in R:关于如何在 R 中的 SOM 中绘制六边形网格的问题:
R package Kohonen - how to plot hexagons instead of circles as in Matlab SOM toolbox? R 包 Kohonen - 如何在 Matlab SOM 工具箱中绘制六边形而不是圆形?
Changing改变
som(data=data, ...)
to:到:
som(data, ...)
resolved the issue.解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.