1

R の Kohonen パッケージを使用して SOM マップを作成しましたが、マップ上の特定のデータ ポイントの場所を特定したいと考えています。つまり、使用されるシリーズは 2 列で構成されるマトリックスであり、1 行ずつ増加しています。マップ自体または特定の行でこの最後の観測の位置にフラグを付けるにはどうすればよいですか? 私が使用するコードは次のとおりです。

require(kohonen)
pretty_palette <- c("#1f77b4", '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2')
data_train <- na.omit(cbind(dataseries_1,dataseries_2))
data_train_matrix <- as.matrix(scale(data_train))
som_grid <- somgrid(xdim = 10, ydim=10, topo="hexagonal")

som_model <- som(data_train_matrix, 
             grid=som_grid, 
             rlen=100, 
             alpha=c(0.05,0.01), 
             keep.data=TRUE,
             n.hood="circular")

som_cluster <- cutree(hclust(dist(som_model$codes)), 4)
plot(som_model, type="mapping", bgcol =pretty_palette[som_cluster] , main = "Regimes Map")
add.cluster.boundaries(som_model, som_cluster)

任意の助けをいただければ幸いです

ありがとうございました

4

1 に答える 1

0

I have added two line on the top of the code to represent some data. What I would like is to be able to flag on the map which the script plot the location of::

datapoint_to_flag <- tail(data_train_matrix,1)

By inserting a text on the cell with the value (or nearest) to datapoint_to_flag the code I have written so far create some random series then plot them across 4 clusters, the bit that I do not know how to write is the bit that would localise datapoint_to_flag on the map...if this makes sense.

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.01), 
             keep.data=TRUE,
             n.hood="circular")

som_cluster <- cutree(hclust(dist(som_model$codes)), 4)
plot(som_model, type="mapping", bgcol =pretty_palette[som_cluster] , main = "Regimes Map")
add.cluster.boundaries(som_model, som_cluster)

datapoint_to_flag <- tail(data_train_matrix,1)

Thank you

Pierre

于 2014-05-31T14:46:08.433 に答える