R kohonen-输入数据是否自动缩放和居中?
我一直在遵循R Kohonen自组织地图(SOM)的在线示例,该示例建议在计算SOM之前,应将数据集中并缩放 但是,我注意到创建的对象似乎具有“中心”和“缩放”属性,在这种情况下,我是否真的通过先居中和缩放来应用冗余步骤?下面是脚本示例R kohonen-输入数据是否自动缩放和居中?,r,R,我一直在遵循R Kohonen自组织地图(SOM)的在线示例,该示例建议在计算SOM之前,应将数据集中并缩放 但是,我注意到创建的对象似乎具有“中心”和“缩放”属性,在这种情况下,我是否真的通过先居中和缩放来应用冗余步骤?下面是脚本示例 # Load package require(kohonen) # Set data data(iris) # Scale and centre dt <- scale(iris[, 1:4],center=TRUE) # Prepare SOM s
# Load package
require(kohonen)
# Set data
data(iris)
# Scale and centre
dt <- scale(iris[, 1:4],center=TRUE)
# Prepare SOM
set.seed(590507)
som1 <- som(dt,
somgrid(6,6, "hexagonal"),
rlen=500,
keep.data=TRUE)
str(som1)
请注意,在输出的第7行和第10行中有对中心和刻度的引用。我希望您能解释一下这个过程。您的缩放步骤并不是多余的,因为在源代码中没有缩放,在7和10中看到的属性都是来自train数据集的属性。 要检查这一点,只需运行并比较这段代码的结果:
# Load package
require(kohonen)
# Set data
data(iris)
# Scale and centre
dt <- scale(iris[, 1:4],center=TRUE)
#compare train datasets
str(dt)
str(as.matrix(iris[, 1:4]))
# Prepare SOM
set.seed(590507)
som1 <- kohonen::som(dt,
kohonen::somgrid(6,6, "hexagonal"),
rlen=500,
keep.data=TRUE)
#without scaling
som2 <- kohonen::som(as.matrix(iris[, 1:4]),
kohonen::somgrid(6,6, "hexagonal"),
rlen=500,
keep.data=TRUE)
#compare results of som function
str(som1)
str(som2)
#加载包
要求(科奥尼)
#设置数据
数据(iris)
#规模和中心
dt
# Load package
require(kohonen)
# Set data
data(iris)
# Scale and centre
dt <- scale(iris[, 1:4],center=TRUE)
#compare train datasets
str(dt)
str(as.matrix(iris[, 1:4]))
# Prepare SOM
set.seed(590507)
som1 <- kohonen::som(dt,
kohonen::somgrid(6,6, "hexagonal"),
rlen=500,
keep.data=TRUE)
#without scaling
som2 <- kohonen::som(as.matrix(iris[, 1:4]),
kohonen::somgrid(6,6, "hexagonal"),
rlen=500,
keep.data=TRUE)
#compare results of som function
str(som1)
str(som2)