我正在尝试在R中使用som
包,即使我使用的是som包附带的示例数据,它仍然会给我一个错误。当我昨天尝试相同的示例数据集时,它工作。我现在很困惑..
这是代码
library(som)
library(class)
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 = factor(wine.classes[training]))
table(wine.classes[-training], som.prediction$prediction)
我得到的错误是如此通用,我无法理解究竟是什么
som.wines <- som(Xtraining, grid = somgrid(5, 5, "hexagonal"))
Error in !toroidal : invalid argument type
答案 0 :(得分:0)
现在Rstudio上的代码正常运行。出于某种原因,即使我没有改变任何东西,也不会再抛出错误了。