Reputation: 1274
I'm trying to run the som function if the Kohonen package
:
library(kohonen)
library(datasets)
data1=iris
dim(iris)
data_train <-data1[sample(nrow(data1),20),1:4]
data_train_matrix <- as.matrix(scale(data_train))
som_grid <- somgrid(xdim = 40, ydim=50, topo="hexagonal")
som_model <- som(data_train_matrix, grid=som_grid, rlen=1, alpha=c(0.05,0.01), keep.data = TRUE )
Unfortunately, I got the following error :
Error in sample.int(length(x), size, replace, prob) : cannot take a sample larger than the population when 'replace = FALSE' Calls: som -> supersom -> sample -> sample.int Execution halted
I didn't understand what this error means.
Thank you in advance for your help!
Upvotes: 0
Views: 98
Reputation: 1274
I solved the pb , you could close the question :
library(kohonen)
library(datasets)
data1=iris
head(data1)
data1.train <- as.matrix(scale(data1[,-5]))
dim(iris)
head(data1.train)
set.seed(100)
data1.grid <- somgrid(xdim = 10, ydim = 10, topo = "hexagonal")
data1.model <- som(data1.train , data1.grid , rlen = 500, radius = 2.5, keep.data = TRUE, dist.fcts = "euclidean")
plot(data1.model, type = "mapping", pchs = 19, shape = "round")
Upvotes: 0