1
https://spark.apache.org/docs/latest/mllib-optimization.html
星火文件下面二元分类预测的示例代码段:
val model = new LogisticRegressionModel(
Vectors.dense(weightsWithIntercept.toArray.slice(0,weightsWithIntercept.size - 1)),
weightsWithIntercept(weightsWithIntercept.size - 1))
// Clear the default threshold.
model.clearThreshold()
// Compute raw scores on the test set.
val scoreAndLabels = test.map { point =>
val score = model.predict(point.features)
(score, point.label)
正如你看到的model.prediction(point.features)返回原始分数,它是超平面分离距离的边界。
我的问题是:
(1)我怎么能知道,如果基于上述计算原始分数的预测类别标签是0或1?
或者
(2)如何推断预测类别标签(0或1)在从上述计算原始分数这种二元分类情况?
如何获得算法确定的计算ROC曲线的最佳阈值? – Tom
在度量对象上,您可以通过各种度量的阈值获取得分。例如:val f1Score = metrics.fMeasureByThreshold。然后你可以迭代找到最好的阈值细节:https://spark.apache.org/docs/latest/mllib-evaluation-metrics.html –