我必須對包含800K文本的文本分類做一些工作。我一直在試圖運行我在下面的鏈接找到了一個實際的例子:R 800K文檔的文本分類
http://garonfolo.dk/herbert/2015/05/r-text-classification-using-a-k-nearest-neighbour-model/
所有一直順利,直到我有以下指令:
# Transform dtm to matrix to data frame - df is easier to work with
mat.df <- as.data.frame(data.matrix(dtm), stringsAsfactors = FALSE)
後運行幾個小時我得到了一個錯誤信息:
Error: cannot allocate vector of size 583.9 Gb
In addition: Warning messages:
1: In vector(typeof(x$v), prod(nr, nc)) :
Reached total allocation of 8076Mb: see help(memory.size)
2: In vector(typeof(x$v), prod(nr, nc)) :
Reached total allocation of 8076Mb: see help(memory.size)
3: In vector(typeof(x$v), prod(nr, nc)) :
Reached total allocation of 8076Mb: see help(memory.size)
4: In vector(typeof(x$v), prod(nr, nc)) :
Reached total allocation of 8076Mb: see help(memory.size)
有沒有辦法克服這個錯誤?
是否有可能例如分割data.matrix(dtm)以塊運行作業,然後以某種方式合併它們?或者更好地以另一種方式或Python進行處理?
感謝
_「有沒有辦法來克服這個錯誤?」_ - 把它留在稀疏矩陣格式中,'dtm'可能在? – lukeA
你可以購買584 Gb的RAM ......或者嘗試使用'removeSparseTerms()'來降低矩陣的大小 – scoa
移動到Python會如何幫助?它不會奇蹟般地爲您的系統增加更多的內存。這是一種方法問題,而不是工具,聽起來您需要對流操作進行更多的研究。 Spark(與'sparklyr'有良好的接口)可以很容易地執行[streaming k-means](http://spark.apache.org/docs/latest/mllib-clustering.html)。 – hrbrmstr