data(wines)
set.seed(7)
kohmap <- xyf(scale(wines), classvec2classmat(wine.classes),
grid = somgrid(5, 5, "hexagonal"), rlen=100)
plot(kohmap, type="changes", main="plot of changes")
plot(kohmap, type="codes", main="codes plot")
plot(kohmap, type="counts", main="counts plot")
plot(kohmap, type="mapping",
labels=wine.classes, col=wine.classes,
main="mapping plot")
xyfpredictions <- predict(kohmap, newdata=kohmap$codes)$classif
bgcols <- c("gray", "pink", "lightgreen")
plot(kohmap, type="mapping", col=wine.classes,
pchs=wine.classes, bgcol=bgcols[as.integer(xyfpredictions)],
main="another mapping plot")
plot(kohmap, type="prediction",
labels=paste("Variety", 1:3),
palette.name = rainbow,
main="unit class prediction", cex=.8)
### Plot mean distance of mapped objects to their unit codebook vector
hits <- sort(unique(kohmap$unit.classif))
distances <- rep(NA, 25)
for (i in seq(along=hits))
distances[hits[i]] <- mean(kohmap$distances[kohmap$unit.classif == hits[i]])
plot(kohmap, type="property", property=distances,
main="property plot: mean distances")
Run the code above in your browser using DataLab