首先,我是 DataBricks 和 PySpark 的新手,所以如果这是我没有看到的简单解决方案,我深表歉意。我的集群位于 DataBricks 运行时 9.1 LTS(Spark 3.1.2、Scala 2.12)上。
我正在研究一个 NLP 入门问题,进行餐厅评论情绪分析。我使用各种注释和逻辑回归模型构建了管道。我正在尝试实现 CrossValidator 对象来调整我的参数。
当我尝试使用 CrossValidator 时,收到以下警告:
/databricks/spark/python/pyspark/ml/util.py:92: UserWarning: CrossValidator_0c70efdbf04c
fit call failed but some spark jobs may still running for unfinished trials.
To address this issue, you should enable pyspark pinned thread mode.
以下错误追溯到我的 fit() 调用:
IllegalArgumentException: requirement failed: Tensorflow model has not been initialized
我的 CrossValidator 代码如下:
pipe_added = Pipeline().setStages([pipe_sw_cstm, lr])
cv = CrossValidator(estimator = pipe_added,
estimatorParamMaps = lr_params,
evaluator = BinaryClassificationEvaluator(),
numFolds = 3,
seed = 31415
)
cvModel = cv.fit(train)
这一切都应该在循环内运行并迭代不同的初始管道,这些初始管道与所需的模型组合到变量中pipe_added
。这个新的复合管道将与所需模型的参数列表一起发送到 CrossValidator。我在这里删除了大部分迭代代码,转而使用静态版本进行调试。
不使用 CrossValidator 对象时,Logistic 回归模型可以正确拟合数据
明显的第一步是启用固定线程模式,我尝试在集群环境变量中设置以下内容
PYSPARK_PIN_THREAD=true
但现在我在运行代码时遇到新错误,fit() 调用仍然失败:
AttributeError: 'GatewayClient' object has no attribute 'thread_connection'
所以看来我应该单独保留固定线程模式。
我尝试导入tensorflow以及mlflow.tensorflow,但没有成功。任何支持将不胜感激,调试库之间的依赖关系已经是我的弱点,更不用说在使用新主库的新平台上了。
编辑 1:使用 TrainValidationSplit 会引发相同的警告和错误。