首页 > 解决方案 > Python H2O 脚本:结束/关闭时的 TypeErrors

问题描述

文件h2otest.py包含https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/glm.html上的代码的缩短版本:

import h2o
h2o.init()
from h2o.estimators.glm import H2OGeneralizedLinearEstimator
prostate = h2o.import_file("https://h2o-public-test-data.s3.amazonaws.com/smalldata/prostate/prostate.csv")
prostate['CAPSULE'] = prostate['CAPSULE'].asfactor()
prostate['RACE'] = prostate['RACE'].asfactor()
prostate['DCAPS'] = prostate['DCAPS'].asfactor()
prostate['DPROS'] = prostate['DPROS'].asfactor()
predictors = ["AGE", "RACE", "VOL", "GLEASON"]
response_col = "CAPSULE"
glm_model = H2OGeneralizedLinearEstimator(family="binomial", lambda_= 0, compute_p_values=True)
glm_model.train(predictors, response_col, training_frame= prostate)
print('Finished')

我在 Conda 环境pycharm中的命令行上运行代码,其中 h2o 3.30.1.3 是从 PyPi 安装的。我正在使用 Python 3.8。我在我的 Mac 和 Linux 服务器上都遇到了同样的错误。启动时没有现有的 H2O 服务器:

(pycharm) $> python h2otest.py

该代码完成了它的工作,但在最后给出了错误消息:

...
Parse progress: |█████████████████████████████████████████████████████████████████████████████| 100%
glm Model Build progress: |███████████████████████████████████████████████████████████████████| 100%
Finished
Closing connection _sid_a7a8 at exit
H2O session _sid_a7a8 closed.
Exception ignored in: <function ExprNode.__del__ at 0x7f9ee65f83a0>
Traceback (most recent call last):
  File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 204, in __del__
  File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 258, in rapids
TypeError: 'NoneType' object is not callable
Exception ignored in: <function ExprNode.__del__ at 0x7f9ee65f83a0>
Traceback (most recent call last):
  File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 204, in __del__
  File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 258, in rapids
TypeError: 'NoneType' object is not callable
Exception ignored in: <function ExprNode.__del__ at 0x7f9ee65f83a0>
Traceback (most recent call last):
  File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 204, in __del__
  File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 258, in rapids
TypeError: 'NoneType' object is not callable
Exception ignored in: <function ExprNode.__del__ at 0x7f9ee65f83a0>
Traceback (most recent call last):
  File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 204, in __del__
  File "/Users/geiringesandnes/miniconda3/envs/pycharm/lib/python3.8/site-packages/h2o/expr.py", line 258, in rapids
TypeError: 'NoneType' object is not callable

我怎样才能摆脱那些错误信息?

标签: python-3.xcommand-lineh2o

解决方案


推荐阅读