# Precision-Recall plot

**URL:** <https://discuss.elastic.co/t/precision-recall-plot/251232>\
**Category:** Kibana\
**Created:** [October 7, 2020, 8:24am UTC](https://discuss.elastic.co/t/precision-recall-plot/251232 "2020-10-07T08:24:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene\_Dobrovolskyi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_dobrovolskyi/32/75364_2.png) [@Eugene\_Dobrovolskyi](https://discuss.elastic.co/u/Eugene_Dobrovolskyi)\
**Post date:** [October 7, 2020, 8:24am UTC](https://discuss.elastic.co/t/precision-recall-plot/251232/1 "2020-10-07T08:24:20Z")

</div>

Hi all,

I would like to build a Precision-Recall plot (for detection data of machine learning domain ). I have the next data in my ElasticSearch index:

- detection result ("true positive", "true negative", "false positive" or "false negative")
- confidence threshold ( value in a range [0,1] )

What I need:

- calculate Precision = count(TP) / ( count(TP) + count(FP) )
- calculate Recall = count(TP) / ( count(TP)+ count(FN) )

Precision and recall should be calculated for values for confidence in different ranges, by example:

- precision and recall for values where confidence threshold \> 0.3
- precision and recall for values where confidence threshold \> 0.5
- precision and recall for values where confidence threshold \> 0.9

And then I need to plot all calculated precision and recall values I one plot ( i already know how to do this task).

Could you please advise how I can calculate precision and recall values per confidence value and then reuse them in another plot?

thank you in advance

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [October 14, 2020, 10:18am UTC](https://discuss.elastic.co/t/precision-recall-plot/251232/2 "2020-10-14T10:18:35Z")

</div>

Hi, unfortunately, this plot and the calculation can be done solely in Vega at the moment.  
TSVB visualization allows you do such kind of calculation but it can't render non-temporal x-axis charts, the standard line chart can show also non-temporal but can not do such kind of calculation, unfortunately.

---

<div class="post-metadata">

**Author:** ![Eugene\_Dobrovolskyi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_dobrovolskyi/32/75364_2.png) [@Eugene\_Dobrovolskyi](https://discuss.elastic.co/u/Eugene_Dobrovolskyi)\
**Post date:** [October 17, 2020, 8:21am UTC](https://discuss.elastic.co/t/precision-recall-plot/251232/3 "2020-10-17T08:21:58Z")

</div>

many thanks  
i will follow your advice

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 14, 2020, 8:21am UTC](https://discuss.elastic.co/t/precision-recall-plot/251232/4 "2020-11-14T08:21:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
