'DataFrame' 对象没有属性 'split_frame'

'DataFrame' object has no attribute 'split_frame'

无法使用 split_frame() 拆分帧。数据框能够显示()但我无法拆分它。请帮忙。

下面是我使用过的代码示例。

from h2o.estimators.random_forest import H2ORandomForestEstimator
from h2o.estimators.gbm import H2OGradientBoostingEstimator
from h2o.estimators.deeplearning import H2ODeepLearningEstimator
from h2o.estimators.glm import H2OGeneralizedLinearEstimator
from h2o.estimators.stackedensemble import H2OStackedEnsembleEstimator
from __future__ import print_function

temp = spark.read.option("header","true").option("inferSchema","true").csv("hdfs://bda-ns/user/august_week2.csv")

train,test,valid = temp.split_frame(ratios=[.75, .15])

预期:没有错误。数据分为测试和训练数据框。 实际:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/cloudera/parcels/SPARK2-2.3.0.cloudera2-1.cdh5.13.3.p0.316101/lib/spark2/python/pyspark/sql/dataframe.py", line 1182, in __getattr__
    "'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
AttributeError: 'DataFrame' object has no attribute 'split_frame'
>>> train,test,valid = temp.split_frame(ratios=[.75, .15])
Traceback (most recent call last):
  File "/opt/cloudera/parcels/SPARK2-2.3.0.cloudera2-1.cdh5.13.3.p0.316101/lib/spark2/python/pyspark/context.py", line 234, in signal_handler

您可以在您的 spark 数据帧上使用 randomsplit

如果您想使用 H2O-3 split_frame 方法,您首先必须将火花框架转换为水框架。在这种情况下,您可以使用 hc.as_h2o_frame(spark_df),其中 hc 是您的 h2o_context(注意:您还需要创建 h2o_context 才能正常工作)。