H2O is an Open Source, Distributed, Fast & Scalable Machine Learning Platform: Deep Learning, Gradient Boosting (GBM) & XGBoost, Random Forest, Generalized Linear Modeling (GLM with Elastic Net), K-Means, PCA, Generalized Additive Models (GAM), RuleFit, Support Vector Machine (SVM), Stacked Ensembles, Automatic Machine Learning (AutoML), etc.
Our Python implementation of {{H2OFrame}} truthness is very inconsistent:
Python2: we override {{__nonzero__}} to support boolean conversion in Py2
{code}
bool(h2o.H2OFrame()) # raise AssertionError
bool(h2o.H2OFrame([])) # False
bool(h2o.H2OFrame([1]) # True
bool(h2o.H2OFrame([1, 1]) # raise H2OValueError from our nonzero impl
{code}
Python3: we don't override {{__bool__}}, therefore delegating boolean conversions to {{__len__}} in Py3 and skipping {{__nonzero__}} logic
{code}
bool(h2o.H2OFrame()) # raise AssertionError
bool(h2o.H2OFrame([])) # False
bool(h2o.H2OFrame([1]) # True
bool(h2o.H2OFrame([1, 1]) # True
{code}
compare with Pandas DataFrame:
{code}
bool(pandas.DataFrame()) # raise ValueError: the truth value of a DataFrame is ambiguous.
bool(pandas.DataFrame([])) # raise ValueError...
bool(pandas.DataFrame([1]) # raise ValueError...
bool(pandas.DataFrame([1, 1]) # raise ValueError...
{code}
Our Python implementation of {{H2OFrame}} truthness is very inconsistent:
Python2: we override {{__nonzero__}} to support boolean conversion in Py2 {code} bool(h2o.H2OFrame()) # raise AssertionError bool(h2o.H2OFrame([])) # False bool(h2o.H2OFrame([1]) # True bool(h2o.H2OFrame([1, 1]) # raise H2OValueError from our nonzero impl {code}
Python3: we don't override {{__bool__}}, therefore delegating boolean conversions to {{__len__}} in Py3 and skipping {{__nonzero__}} logic {code} bool(h2o.H2OFrame()) # raise AssertionError bool(h2o.H2OFrame([])) # False bool(h2o.H2OFrame([1]) # True bool(h2o.H2OFrame([1, 1]) # True {code}
compare with Pandas DataFrame: {code} bool(pandas.DataFrame()) # raise ValueError: the truth value of a DataFrame is ambiguous. bool(pandas.DataFrame([])) # raise ValueError... bool(pandas.DataFrame([1]) # raise ValueError... bool(pandas.DataFrame([1, 1]) # raise ValueError... {code}