Error in !toroidal : invalid argument type in R with som package

﹥>﹥吖頭↗ 提交于 2020-01-05 09:12:17

问题


I am trying to use som package in R and even though I am using the example data that comes with som package, it is still giving me an error. When i tried the same example dataset yesterday it worked. I am confused now..

Here is the code

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)

The error I am getting is so generic and I am not been able to understand what exactly it is

som.wines <- som(Xtraining, grid = somgrid(5, 5, "hexagonal"))
Error in !toroidal : invalid argument type

回答1:


The code is working normally now on Rstudio. For some reason, it is not throwing the error anymore even though I haven't changed anything.



来源:https://stackoverflow.com/questions/44424757/error-in-toroidal-invalid-argument-type-in-r-with-som-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!