首页 > 解决方案 > 'Param' 对象上的错误不可调用 - 用于推荐系统的 Apache Spark

问题描述

我正在使用 apache spark 作为推荐系统。在评估部分,为了找到准确率和召回率,我得到了错误。

代码如下所述


def print_metrics(predictions_and_labels):
    metrics = MulticlassMetrics(predictions_and_labels)
    print('Precision of True ', metrics.precision(1))
    print('Precision of False', metrics.precision(0))
    print('Recall of True    ', metrics.recall(1))
    print('Recall of False   ', metrics.recall(0))
    print('F-1 Score         ', metrics.fMeasure())
    print('Confusion Matrix\n', metrics.confusionMatrix().toArray())

predictions = model.transform(testRatings)
accuracy = model.predictionCol().evaluate(predictions)
print('F1 Accuracy: %f' % accuracy)

predictions_and_labels = predictions.select("prediction", "foreclosure_status").rdd \
.map(lambda r: (float(r[0]), float(r[1])))

print_metrics(predictions_and_labels)

我提到的错误是

“'Param' 对象不可调用”。

请任何人都可以建议我解决方案。提前致谢。

标签: pysparkrecommender-systems

解决方案


推荐阅读