Description Usage Arguments Value Note Author(s) See Also Examples
Map objects to a supervised GrowingSOM map, and return for each object the property associated with the corresponding winning node.
1 2 |
object |
a trained supervised gsom object. (see train_xy.gsom) |
df |
Matrix or Dataframe of observations for which the Y values should be predicted. |
retaindata |
logical. If set to TRUE a copy of the mapped data (df) is stored as a copy in the returned gsom object. |
... |
not used. |
gsom object containing the following information:
nodes$position |
Coordinates of the units of the map (copied from the input gsom map) |
nodes$codes |
a matrix containing the codes for each variable of each node (copied from the input gsom map) |
nodes$predict |
a matrix containing the codes for each property that are to be modelled (copied from the input gsom map) |
nodes$freq |
the number of observations that were mapped to each node. |
prediction$bmn |
best matching node for each observation provided. |
prediction$dist |
distance measurement of observations to their best matching units. |
prediction$value |
prediction for the modelled properties for each observation. |
Distance Measurement: The following Formula is used for determining the distance from the best matching unit:
sqrt((sum(df-code))^2 / Dimenstions)
This is a different scale than is used by the kohonen package.
Alex Hunziker
train_xy.gsom, map.gsom
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # load data
data("auto_mpg")
s = sample(1:392, 300)
train_set = auto_mpg[s,1:8]
test_set = auto_mpg[-s,1:8]
# Train Gsom Model (hexagonal grid)
gsom_map <- train_xy.gsom(train_set[,2:8], train_set[,1], spreadFactor = 0.9, nhood="hex")
print(gsom_map)
plot(gsom_map, type = "predict")
# Predict mpg for the test set
gsom_predictions = predict.gsom(gsom_map, test_set[,2:8])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.