pyspark - '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' 对象不可调用”。
请任何人都可以建议我解决方案。提前致谢。
解决方案
推荐阅读
- network-programming - 线上的平面缓冲区
- c# - How to Pass data between ViewModels WPF, MVVM
- powershell - How to run a powershell script with different credentials
- angular6 - Angular6 无管道组合最新
- python - 在 for 循环中连接数据帧
- python - 我想使用正则表达式拆分文件的扩展名
- odoo - Onchange 仅触发一次
- ibm-cloud - IBM Watson Assistant:聊天机器人实体混淆正则表达式
- python - AbstractUser 不工作 Django !(替换自定义用户模型)
- c# - 如何确保 RSACryptoServiceProvider 始终创建新的密钥对?