How to get sparse matrices into H2O?

我的未来我决定 提交于 2019-11-28 07:39:34

问题


I am trying to get a sparse matrix into H2O and I was wondering whether that was possible. Suppose we have the following:

test <- Matrix(c(1,0,0,1,1,1,1,0,1), nrow = 3, sparse = TRUE)

and assuming my local H2O is localH2O, I can't seem to do the following:

as.h2o(test)

It gives the error: cannot coerce class "structure("dgCMatrix", package = "Matrix")" to a data.frame. That seems to be pretty logical, however assuming that test is so big that I can't transform it into a dataframe, how am I suppose to load this into H2O? Using a sparse matrix representation it is only 500MB or so.

How can I load a sparse matrix into H2O?


回答1:


It is cumbersome to transport data stored in R's memory to H2O's memory for essentially two reasons: R performs a POST of the file to stream up the data into H2O, which 1) doesn't take advantage of H2O's parallel reader, and 2) limits your data to existing in R.

Instead, make use of the h2o.importFile method from R to make use of H2O's parallel reader. Your data can live anywhere: HDFS, S3, regular filesystem...

H2O sports an SVMLight reader, so it is recommended to save your sparse Matrix from R in svmlight format.

Hope this helps!



来源:https://stackoverflow.com/questions/32843267/how-to-get-sparse-matrices-into-h2o

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