predict.kohonen {kohonen} | R Documentation |
Map objects to a trained Kohonen map, and return for each object the
property associated with the corresponding winning unit. For
som
and supersom
maps, the unit properties are
calculated using explicit arguments trainX
and trainY
;
for xyf
and bdk
maps, the predicted properties are the
Y-codebookvectors. Note that in the latter case only the X-space is
used for prediction.
## S3 method for class 'kohonen': predict(object, newdata, trainX, trainY, unit.predictions, threshold = 0, whatmap = NULL, weights = 1, ...)
object |
Trained network. |
newdata |
Data matrix for which predictions are to be made. If not given, defaults to the training data (when available). |
trainX |
Training data for obtaining predictions for unsupervised
maps; necessary for som maps trained with the
keep.data = FALSE option. |
trainY |
Values for the dependent variable for the training data;
necessary for som and supersom maps. |
unit.predictions |
Possible override of the predictions for each unit. |
threshold |
Used in class predictions; see
classmat2classvec . |
whatmap |
For supersom maps: what layers to use in the
mapping. |
weights |
For supersom maps: weights of layers uses in the
mapping. |
... |
Currently not used. |
Returns a list with components
prediction |
predicted values for the properties of interest. |
unit.classif |
unit numbers to which objects in the data matrix are mapped. |
unit.predictions |
property values associated with map units. |
Ron Wehrens
data(wines) set.seed(7) training <- sample(nrow(wines), 120) Xtraining <- scale(wines[training, ]) Xtest <- scale(wines[-training, ], center = attr(Xtraining, "scaled:center"), scale = attr(Xtraining, "scaled:scale")) som.wines <- som(Xtraining, grid = somgrid(5, 5, "hexagonal")) som.prediction <- predict(som.wines, newdata = Xtest, trainX = Xtraining, trainY = classvec2classmat(wine.classes[training])) table(wine.classes[-training], classmat2classvec(som.prediction$prediction))