Description Usage Arguments Value Note Author(s) See Also Examples
View source: R/predict.hdgsom.r
Map objects to a supervised HDGSOM map, and return for each object the property associated with the corresponding winning node.
1 2 |
object |
a trained supervised hdgsom object. (see train_xy.hdgsom) |
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 hdgsom object. |
... |
not used. |
hdgsom object containing the following information:
nodes$position |
Coordinates of the units of the map (copied from the input hdgsom map) |
nodes$codes |
a matrix containing the codes for each variable of each node (copied from the input hdgsom map) |
nodes$predict |
a matrix containing the codes for each property that are to be modelled (copied from the input hdgsom 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.hdgsom, map.hdgsom
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 hdgsom Model (hexagonal grid)
hdgsom_map <- train_xy.hdgsom(train_set[,2:8], train_set[,1], spreadFactor = 0.9, nhood="hex")
print(hdgsom_map)
plot(hdgsom_map, type = "predict")
# Predict mpg for the test set
hdgsom_predictions = predict.hdgsom(hdgsom_map, test_set[,2:8])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.