全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2542 0
2015-05-04
```{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'请教高手,这是什么原因?
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群