如何将稀疏矩阵转换为H2O? [英] How to get sparse matrices into H2O?

查看:131
本文介绍了如何将稀疏矩阵转换为H2O?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将稀疏矩阵放入 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)

并假设我的本地H2O是localH2O,我似乎无法执行以下操作:

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

as.h2o(test)

它给出错误:cannot coerce class "structure("dgCMatrix", package = "Matrix")" to a data.frame.这似乎很合乎逻辑,但是假设测试太大,以至于我无法将其转换为数据帧,那么我该如何将其加载到H2O中呢?使用稀疏矩阵表示,只有500MB左右.

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.

如何将稀疏矩阵加载到H2O中?

How can I load a sparse matrix into H2O?

推荐答案

将存储在R的内存中的数据传输到H2O的内存很麻烦,这主要有两个原因:R执行文件的POST以将数据流式传输到H2O,其中1)不利用H2O的并行读取器,以及2)将您的数据限制为R中存在.

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.

相反,请使用R中的h2o.importFile方法来使用H2O的并行读取器.您的数据可以存放在任何地方:HDFS,S3,常规文件系统...

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具有SVMLight读取器,因此建议将R中的稀疏矩阵以svmlight格式保存.

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

希望这会有所帮助!

这篇关于如何将稀疏矩阵转换为H2O?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆