I am trying to  write a code  to create a Self Organising MAP  for a risk
regime  application. I have managed to assemble a few lines to create the
MAP and I would now like to label  on the MAP each 4 individual region  as
"A", "B" "C" & "D" as  well as   showing on the MAP where were the last two
points, ideally by creating a label on the MAP showing  clearly the
respective dates or   a specific  flag. My code is in the below. I would be
very thankful If someone  with experience with  the kohonen package  could
help me out or point me to a more appropriate forum if this one is not. 

 

 

Kind regards

 

Pierre

 

 

"

require(kohonen)

pretty_palette <- c("#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd',
'#8c564b', '#e377c2')

dataseries1 <- rnorm(1000, mean = 0, sd = 3)

dataseries2 <- rnorm(1000, mean = 0, sd = 1)

data_train <- na.omit(cbind(dataseries1,dataseries2))

data_train_matrix <- as.matrix(scale(data_train))

som_grid <- somgrid(xdim = 20, ydim=20, topo="hexagonal")

 

som_model <- som(data_train_matrix, 

                 grid=som_grid, 

                 rlen=1000, 

                 alpha=c(0.05,0.005), 

                 keep.data=TRUE,

                 n.hood="circular")

 

som_cluster <- cutree(hclust(dist(som_model$codes)), 4)   # this creates the
4 regions I would like to label on the MAP (i.e eeither as legend  labels
next to the map, or on the MAP itself) 

plot(som_model, type="mapping", bgcol =pretty_paltte[som_cluster] , main =
"Map") #"dist.neighbours", "mapping", "property", "quality")

add.cluster.boundaries(som_model, som_cluster

 

datapoint_to_flag <- tail(data_train_matrix,2)  #### those are the points I
would like to mark / label on the map

 

 

 

"

 


	[[alternative HTML version deleted]]

