楼主: zst-1981
2612 0

[问答] 请教SOM作图问题 [推广有奖]

  • 0关注
  • 0粉丝

高中生

37%

还不是VIP/贵宾

-

威望
0
论坛币
1 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
271 点
帖子
12
精华
0
在线时间
33 小时
注册时间
2015-2-5
最后登录
2022-7-3

楼主
zst-1981 发表于 2015-5-4 16:52:19 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
```{r=Creating SOMs in R}
#Install the kohonen package
install.packages("kohonen")
#load the kohonen package
library(kohonen)
# Create a training data set (rows are samples, columns are variables)
setwd("D:\\workingdirectory")
data_train<-read.csv("CD44.csv")
# Change the data frame with training data to a matrix
# Also center and scale all variables to give them equal importance during
# the SOM training process.
row.names<-data_train[,1]
data_train_matrix <- as.matrix(scale(data_train[,-1]))
# Create the SOM Grid - you generally have to specify the size of the
# training grid prior to training the SOM. Hexagonal and Circular
# topologies are possible
som_grid <- somgrid(xdim = 7, ydim=30, topo="hexagonal")
# Finally, train the SOM, options for the number of iterations,
# the learning rates, and the neighbourhood are available
som_model <- som(data_train_matrix,
   grid=som_grid,
  rlen=100,
  alpha=c(0.05,0.01),
  keep.data = TRUE,
  n.hood="circular")
```

最后一步的结果是
Error in sample.int(length(x), size, replace, prob) :   cannot take a sample larger than the population when 'replace = FALSE'请教高手,这是什么原因?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:作图问题 SOM Variables directory Packages training package Create

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-10 02:59