numpytypeerrorxgboosth2ohyperopt

H2OTypeError: Argument should be an ?integer, got int64 [3.30.1.1]


I'm trying a simple use of hyperopt with H2O XGBoost for which I'm taking elements out of a numpy array for the parameters, but I'm getting this H2OTypeError and I don't understand why the condition of ?integer isn't met by int64.

To simplify the example, H2O XGBoost does work when called as:

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

But the following returns this H2OTypeError:

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

...

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

I can work around the error for now, but I don't understand it.


Solution

  • H2O is expecting a native Python int, but you are passing a numpy int64. More is explained here about the differences.

    Try converting the numpy array into a list max_depth=np.arange(10,11,1).tolist()[0]