计算 h2o 帧的哈希值

Calculate hash of an h2o frame

我想计算一个 h2o.frame.H2OFrame 的哈希值。理想情况下,在 Rpython 中。我对 h2o.frame.H2OFrame 的理解是这些对象基本上 "live" 在 h2o 服务器上(即由一些 Java 对象表示)而不是 Rpython 可能是从哪里上传的。

我想计算哈希值"as close as possible"到实际的训练算法。这排除了计算底层 Rpython 对象(的序列化)以及加载数据的任何底层文件的哈希值。 这样做的原因是我想捕获 h2o 的上传函数对基础数据执行的所有(可能)更改。

h2o docs 推断,没有通过 h2o.frame.H2OFrame 公开类似散列的功能。 实现 h2o 数据的类似散列摘要的一种可能性是通过对所有数字列求和并对分类列执行类似的操作。但是,我真的很想在我的散列函数中产生一些雪崩效应,以便函数输入的微小变化会导致输出的巨大差异。此要求排除了简单的求和等。

是否已经有一些我可能忽略的界面? 如果没有,我怎样才能完成上述任务?

import h2o
h2o.init()
iris_df=h2o.upload_file(path="~/iris.csv")

# what I would like to achieve
iris_df.hash()
# >>> ab2132nfqf3rf37 

# ab2132nfqf3rf37 is the (made up) hash value of iris_df

感谢您的帮助。

它在 REST API 1 中可用(见屏幕截图)您也可以在 Python 中的 H2OFrame 对象中找到它,但它不会直接公开。

这里是 python 中基于 Michal Kurka 和 Tom Kraljevic 的建议的完整解决方案:

import h2o
import requests
import json

h2o.init()

iris_df = h2o.upload_file(path="~/iris.csv")

apiEndpoint = "http://127.0.0.1:54321/3/Frames/"
res = json.loads(requests.get(apiEndpoint + iris_df.frame_id).text)

print("Checksum 1: ", res["frames"][0]["checksum"])

#change a bit
iris_df[0, 1] = iris_df[0, 1] + 1e-3

res = json.loads(requests.get(apiEndpoint + iris_df.frame_id).text)

print("Checksum 2: ", res["frames"][0]["checksum"])

h2o.cluster().shutdown()

这给了

Checksum 1:  8858396055714143663
Checksum 2:  -4953793257165767052

感谢您的帮助!