Search code examples
h2o

h2o hit_ratio_table AttributeError


I'm following a tutorial from https://github.com/h2oai/h2o-tutorials/blob/master/tutorials/gbm-randomforest/GBM_RandomForest_Example.py

I have been following the tutorial until I reached the line with hit_ratio_table. when I executed "rf_v1.hit_ratio_table(valid=True)", I encounter the error below.

>>> rf_v1.hit_ratio_table(valid=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/h2oUser/sparkling-water-2.3.0/py/build/dist/h2o_pysparkling_2.3-2.3.0.zip/h2o/utils/backward_compatibility.py", line 74, in __getattr__
  File "/home/h2oUser/sparkling-water-2.3.0/py/build/dist/h2o_pysparkling_2.3-2.3.0.zip/h2o/utils/backward_compatibility.py", line 49, in __getattribute__
AttributeError: type object 'H2ORandomForestEstimator' has no attribute 'hit_ratio_table'

I tried to search if hit_ratio_table is being deprecated or not, but I can't find any links. Does anyone know if this function has been changed?


Solution

  • The attribute is still there, it looks like the tutorial is missing a line of code right after the file import, which means the model is being considered as a regression problem instead of a classification problem. So if you add the following line after you import the covtype dataset:

    covtype_df[54] = covtype_df[54].asfactor()

    which converts the target to a factor, it should work.

    If you want to play around with the hit_ratio_table() you can look at this code snippet in the H2O-3 user guide.