首页 > 解决方案 > H2OTypeError:参数应该是一个?整数,得到 int64 [3.30.1.1]

问题描述

我正在尝试将 hyperopt 与 H2O XGBoost 一起简单地使用,为此我从参数的 numpy 数组中取出元素,但是我得到了这个 H2OTypeError 并且我不明白为什么?integer不满足条件int64.

为简化示例,H2O XGBoost 在调用时确实有效:

xgb = H2OXGBoostEstimator(nfolds=5, max_depth=list(range(10,11))[0])

但以下返回此 H2OTypeError:

xgb = H2OXGBoostEstimator(nfolds=5, max_depth=np.arange(10,11,1)[0])

...

H2OTypeError: Argument `max_depth` should be an ?integer, got int64

我现在可以解决该错误,但我不明白。

标签: numpytypeerrorxgboosth2ohyperopt

解决方案


H2O 期待原生 Python int,但您传递的是numpy int64. 更多关于差异的解释here 。

尝试将 numpy 数组转换为列表max_depth=np.arange(10,11,1).tolist()[0]


推荐阅读