我正在使用 pyspark 数据框。我有一些代码试图在其中转换dataframe
to an rdd
,但我收到以下错误:
AttributeError:“SparkSession”对象没有属性“序列化器”
可能是什么问题?
training, test = rescaledData.randomSplit([0.8, 0.2])
nb = NaiveBayes(smoothing=1.0, modelType="multinomial")
# Train a naive Bayes model.
model = nb.fit(rescaledData)
# Make prediction and test accuracy.
predictionAndLabel = test.rdd.map(lambda p: (model.predict(p.features), p.label))
accuracy = 1.0 * predictionAndLabel.filter(lambda pl: pl[0] == pl[1]).count() / test.count()
print('model accuracy {}'.format(accuracy))
有谁知道为什么该声明test.rdd
导致错误?数据框包含Row object of (label, features)
.
Thanks
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)