在SQL中计算精​​度/召回曲线

时间:2014-01-23 20:30:00

标签: sql machine-learning

假设我有分类决策和信心作为记录,有没有办法通过SQL获得精确/召回曲线?换句话说,有没有办法将以下一组查询合并为一个?

select avg(predicted_label=correct_label) from t where confidence<0
select avg(predicted_label=correct_label) from t where confidence<1
select avg(predicted_label=correct_label) from t where confidence<2
select avg(predicted_label=correct_label) from t where confidence<3
select avg(predicted_label=correct_label) from t where confidence<4
select avg(predicted_label=correct_label) from t where confidence<5
select avg(predicted_label=correct_label) from t where confidence<6
....

2 个答案:

答案 0 :(得分:1)

要获得avg predicted_label的置信区间,请尝试这样做 编辑:在<=

上加入了
SELECT FLOOR(t1.confidence), AVG(t2.predicted_label)
FROM Table t1
    JOIN Table t2 ON t2.confidence <= t1.Confidence
GROUP BY FLOOR(t1.confidence)

答案 1 :(得分:1)

如果您有一个表格(让我们称之为numbers的单列num)包含从0到足够大的数字的相关数字,那么您可以简单地说:

select avg(t.predicted_label=t.correct_label) 
  from t join numbers on t.confidence < numbers.num
 where numbers.num < 100 -- or whatever makes sense
group by numbers.num