小编Cob*_*bra的帖子

在 Pyspark 中评估分类器时,'SparkSession' 对象没有属性 'serializer'

我在批处理模式下使用 Apache spark。我已经建立了一个完整的管道,将文本转换为 TFIDF 向量,然后使用逻辑回归预测一个布尔类:

# Chain previously created feature transformers, indexers and regression in a Pipeline
pipeline = Pipeline(stages=[tokenizer, hashingTF, idf, 
                        labelIndexer, featureIndexer, lr])
#Fit the full model to the training data
model = pipeline.fit(trainingData)

#Predict test data 
predictions = model.transform(testData)
Run Code Online (Sandbox Code Playgroud)

我可以检查predictions,这是一个火花数据框,这正是我所期望的。接下来,我想查看混淆矩阵,因此我将分数和标签转换为 RDD 并将其传递给 BinaryClassificationMetrics():

predictionAndLabels = predictions.select('prediction','label').rdd
Run Code Online (Sandbox Code Playgroud)

最后,我将其传递给 BinaryClassificationMetrics:

metrics = BinaryClassificationMetrics(predictionAndLabels) #this errors out
Run Code Online (Sandbox Code Playgroud)

这是错误:

AttributeError: 'SparkSession' object has no attribute 'serializer'
Run Code Online (Sandbox Code Playgroud)

此错误没有帮助,搜索它会引发广泛的问题。我发现唯一看起来相似的是这篇没有答案的帖子:如何解决错误“AttributeError:'SparkSession' object has no attribute 'serializer'?

任何帮助表示赞赏!

python apache-spark apache-spark-sql pyspark

3
推荐指数
1
解决办法
4122
查看次数

标签 统计

apache-spark ×1

apache-spark-sql ×1

pyspark ×1

python ×1