Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
837 views
in Technique[技术] by (71.8m points)

r - How to get sparse matrices into H2O?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...