R中的NMF无法处理数字数据

时间:2018-10-04 19:54:21

标签: r nmf

我想使用NMF分解手写数字数据(的一部分)。但这给了我一个错误。

我不确定是什么问题。下面是与R会话信息一起给出错误的代码。

请注意,可以使用NNLM库中的nnmf函数处理相同的数据。

# prepare data
dig <- as.matrix(read.csv("https://archive.ics.uci.edu/ml/machine-learning-databases/optdigits/optdigits.tra", header=FALSE))
d <- dig[,65]
dig0246 <- dig[d %in% c(0,2,4,6),1:64]
#run NMF
library(NMF)
res <- nmf(dig0246, 2)
#Error in cons != .consold : non-conformable arrays
#Timing stopped at: 0.89 0 0.92`

sessionInfo()

R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base

other attached packages:
[1] NNLM_0.4.2 doParallel_1.0.14 iterators_1.0.10 foreach_1.4.4
[5] NMF_0.21.0 Biobase_2.38.0 BiocGenerics_0.24.0 cluster_2.0.7-1
[9] rngtools_1.3.1 pkgmaker_0.27 registry_0.5

loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 compiler_3.4.4 pillar_1.3.0 RColorBrewer_1.1-2 plyr_1.8.4
[6] bindr_0.1.1 tools_3.4.4 digest_0.6.17 gridBase_0.4-7 tibble_1.4.2
[11] gtable_0.2.0 pkgconfig_2.0.2 rlang_0.2.2 bibtex_0.4.2 rstudioapi_0.7
[16] bindrcpp_0.2.2 withr_2.1.2 stringr_1.3.1 dplyr_0.7.6 grid_3.4.4
[21] tidyselect_0.2.4 glue_1.3.0 R6_2.2.2 reshape2_1.4.3 purrr_0.2.5
[26] ggplot2_3.0.0 magrittr_1.5 scales_1.0.0 codetools_0.2-15 assertthat_0.2.0
[31] xtable_1.8-3 colorspace_1.3-2 labeling_0.3 stringi_1.1.7 lazyeval_0.2.1
[36] munsell_0.5.0 crayon_1.3.4

0 个答案:

没有答案