我正在 R 中尝试一个 subervised SOM,它适用于 R 版本 3.1.0 但不适用于 3.3.2。这是它在 3.1.0 中正常工作:
> fitControl <- trainControl(method = "repeatedcv",number = 10,repeats = 10)
> somFit1 <- train(Species ~ ., data = iris, method = "xyf",preProc = c("center","scale"),trControl = fitControl,metric="Kappa")
Loading required package: kohonen
Loading required package: class
Loading required package: MASS
Warning messages:
1: package ‘kohonen’ was built under R version 3.1.3
2: package ‘class’ was built under R version 3.1.3
3: package ‘MASS’ was built under R version 3.1.3
> somFit1
Self-Organizing Maps
150 samples
4 predictor
3 classes: 'setosa', 'versicolor', 'virginica'
Pre-processing: centered (4), scaled (4)
Resampling: Cross-Validated (10 fold, repeated 10 times)
Summary of sample sizes: 135, 135, 135, 135, 135, 135, ...
Resampling results across tuning parameters:
xdim ydim xweight Accuracy Kappa Accuracy SD Kappa SD
1 2 0.5 0.6666667 0.500 0.00000000 0.00000000
1 2 0.7 0.6666667 0.500 0.00000000 0.00000000
1 2 0.9 0.6666667 0.500 0.00000000 0.00000000
1 3 0.5 0.8040000 0.706 0.12128012 0.18192017
1 3 0.7 0.8140000 0.721 0.11996820 0.17995229
1 3 0.9 0.8240000 0.736 0.09309252 0.13963878
1 4 0.5 0.8806667 0.821 0.08384423 0.12576634
1 4 0.7 0.8953333 0.843 0.07043555 0.10565333
1 4 0.9 0.8386667 0.758 0.08693819 0.13040729
2 2 0.5 0.8960000 0.844 0.08649296 0.12973944
2 2 0.7 0.8833333 0.825 0.09057740 0.13586610
2 2 0.9 0.8313333 0.747 0.08499290 0.12748935
2 3 0.5 0.8793333 0.819 0.07796226 0.11694339
2 3 0.7 0.9100000 0.865 0.07602646 0.11403969
2 3 0.9 0.9326667 0.899 0.06930471 0.10395706
2 4 0.5 0.9106667 0.866 0.06977276 0.10465914
2 4 0.7 0.9193333 0.879 0.07478814 0.11218221
2 4 0.9 0.9453333 0.918 0.06021287 0.09031930
3 3 0.5 0.9333333 0.900 0.05763775 0.08645662
3 3 0.7 0.9353333 0.903 0.06317808 0.09476713
3 3 0.9 0.9440000 0.916 0.05336699 0.08005049
3 4 0.5 0.9406667 0.911 0.06205967 0.09308951
3 4 0.7 0.9366667 0.905 0.06658244 0.09987366
3 4 0.9 0.9480000 0.922 0.05808775 0.08713162
Tuning parameter 'topo' was held constant at a value of hexagonal
Kappa was used to select the optimal model using the largest value.
The final values used for the model were xdim = 3, ydim = 4, xweight = 0.9
and topo = hexagonal.
在这里它在 3.3.2 中不起作用:
> fitControl <- trainControl(method = "repeatedcv",number = 10,repeats = 10)
> somFit1 <- train(Species ~ ., data = iris, method = "xyf",preProc = c("center","scale"),trControl = fitControl,metric="Kappa")
Loading required package: kohonen
Something is wrong; all the Kappa metric values are missing:
Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :24 NA's :24
Error in train.default(x, y, weights = w, ...) : Stopping
In addition: There were 50 or more warnings (use warnings() to see the first 50)
警告是:
Warning messages:
1: package ‘kohonen’ was built under R version 3.3.3
2: In eval(expr, envir, enclos) :
model fit failed for Fold01.Rep01: xdim=1, ydim=2, xweight=0.5, topo=hexagonal Error in supersom(list(X, Y), ...) :
unused arguments (xweight = 0.5, contin = FALSE)
3: In eval(expr, envir, enclos) :
model fit failed for Fold01.Rep01: xdim=2, ydim=2, xweight=0.5, topo=hexagonal Error in supersom(list(X, Y), ...) :
unused arguments (xweight = 0.5, contin = FALSE)
我觉得未使用的论点很重要。在过去使用插入符号时,当我在对插入符号的调用中删除多余的“verbose = FALSE”参数时,该错误消息已经消失。但是在这里我不知道如何阻止 xweight 和 contin 通过。谢谢。