# How to calculate relevancy by the help of precision and recall

**URL:** https://discuss.elastic.co/t/how-to-calculate-relevancy-by-the-help-of-precision-and-recall/15610
**Category:** Elasticsearch
**Created:** [February 5, 2014, 6:06am UTC](https://discuss.elastic.co/t/how-to-calculate-relevancy-by-the-help-of-precision-and-recall/15610 "2014-02-05T06:06:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Navneet\_Mathpal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/navneet_mathpal/32/3677_2.png) [@Navneet\_Mathpal](https://discuss.elastic.co/u/Navneet_Mathpal)
#### Post date: [February 5, 2014, 6:06am UTC](https://discuss.elastic.co/t/how-to-calculate-relevancy-by-the-help-of-precision-and-recall/15610/1 "2014-02-05T06:06:50Z")

</div>

Hi,

I want to know how do we calculate relevancy with the help of precision and  
reacall,

for example:-  
A = The number of relevant records retrieved,  
B = The number of relevantrecords not retrieved, and  
C = The number of irrelevant records retrieved.  
In this example A = 45, B = 35(80-45)and C = 15(60-45)  
Recall =(45 / (45 + 35)) \* 100% =\> 45/80 \* 100% =56%  
Precision =(45 / (45 + 15)) \* 100% =\> 45/60 \* 100% =75%

what would be its relevancy how how ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0c5e3d1e-b58b-4ff1-a893-0cfbaef87aa8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0c5e3d1e-b58b-4ff1-a893-0cfbaef87aa8%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [February 5, 2014, 7:14am UTC](https://discuss.elastic.co/t/how-to-calculate-relevancy-by-the-help-of-precision-and-recall/15610/2 "2014-02-05T07:14:46Z")

</div>

Interesting topic. Not elasticsearch specific, but nevertheless  
interesting. One method to calculate relevancy given the precision and  
recall of a query is by using the F1 score:

> **[F-score](https://en.wikipedia.org/wiki/F1_score)**
>
> In statistical analysis of binary classification, the F-score or F-measure is a measure of a test's accuracy. It is calculated from the precision and recall of the test, where the precision is the number of true positive results divided by the number of all positive results, including those not identified correctly, and the recall is the number of true positive results divided by the number of all samples that should have been identified as positive. Precision is also known as positive predictive...

F1 would be equal to 2 \* (P \* R) / (P + R), where P is the precision and R  
is the recall.

I am glad someone is using elasticsearch as a search engine. Lately it  
feels like it is mainly an analytical tool. 🙂

Cheers,

Ivan

On Tue, Feb 4, 2014 at 10:06 PM, Navneet Mathpal \<[navneetmathpal93@gmail.com](mailto:navneetmathpal93@gmail.com)

> wrote:

> Hi,
> 
> I want to know how do we calculate relevancy with the help of precision  
> and reacall,
> 
> for example:-  
> A = The number of relevant records retrieved,  
> B = The number of relevantrecords not retrieved, and  
> C = The number of irrelevant records retrieved.  
> In this example A = 45, B = 35(80-45)and C = 15(60-45)  
> Recall =(45 / (45 + 35)) \* 100% =\> 45/80 \* 100% =56%  
> Precision =(45 / (45 + 15)) \* 100% =\> 45/60 \* 100% =75%
> 
> what would be its relevancy how how ?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/0c5e3d1e-b58b-4ff1-a893-0cfbaef87aa8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0c5e3d1e-b58b-4ff1-a893-0cfbaef87aa8%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA2jdxr9G0p9fL6FVx%3DRvt5GH-O2vLsXb2N41OeCA5sw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCA2jdxr9G0p9fL6FVx%3DRvt5GH-O2vLsXb2N41OeCA5sw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Navneet\_Mathpal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/navneet_mathpal/32/3677_2.png) [@Navneet\_Mathpal](https://discuss.elastic.co/u/Navneet_Mathpal)
#### Post date: [February 5, 2014, 7:46am UTC](https://discuss.elastic.co/t/how-to-calculate-relevancy-by-the-help-of-precision-and-recall/15610/3 "2014-02-05T07:46:56Z")

</div>

hey thanks ivan 🙂

On Wednesday, 5 February 2014 12:44:46 UTC+5:30, Ivan Brusic wrote:

> Interesting topic. Not elasticsearch specific, but nevertheless  
> interesting. One method to calculate relevancy given the precision and  
> recall of a query is by using the F1 score:  
> [F-score - Wikipedia](http://en.wikipedia.org/wiki/F1_score)
> 
> F1 would be equal to 2 \* (P \* R) / (P + R), where P is the precision and R  
> is the recall.
> 
> I am glad someone is using elasticsearch as a search engine. Lately it  
> feels like it is mainly an analytical tool. 🙂
> 
> Cheers,
> 
> Ivan
> 
> On Tue, Feb 4, 2014 at 10:06 PM, Navneet Mathpal \<[navneetm...@gmail.com](mailto:navneetm...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi,
> > 
> > I want to know how do we calculate relevancy with the help of precision  
> > and reacall,
> > 
> > for example:-  
> > A = The number of relevant records retrieved,  
> > B = The number of relevantrecords not retrieved, and  
> > C = The number of irrelevant records retrieved.  
> > In this example A = 45, B = 35(80-45)and C = 15(60-45)  
> > Recall =(45 / (45 + 35)) \* 100% =\> 45/80 \* 100% =56%  
> > Precision =(45 / (45 + 15)) \* 100% =\> 45/60 \* 100% =75%
> > 
> > what would be its relevancy how how ?
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/0c5e3d1e-b58b-4ff1-a893-0cfbaef87aa8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0c5e3d1e-b58b-4ff1-a893-0cfbaef87aa8%40googlegroups.com)  
> > .  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ec8db27b-761b-4af5-a59b-fbd7901c5d8c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ec8db27b-761b-4af5-a59b-fbd7901c5d8c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Navneet\_Mathpal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/navneet_mathpal/32/3677_2.png) [@Navneet\_Mathpal](https://discuss.elastic.co/u/Navneet_Mathpal)
#### Post date: [February 5, 2014, 7:51am UTC](https://discuss.elastic.co/t/how-to-calculate-relevancy-by-the-help-of-precision-and-recall/15610/4 "2014-02-05T07:51:51Z")

</div>

Ivan but  
On Wednesday, 5 February 2014 11:36:50 UTC+5:30, Navneet Mathpal wrote:

> Hi,
> 
> I want to know how do we calculate relevancy with the help of precision  
> and reacall,
> 
> for example:-  
> A = The number of relevant records retrieved,  
> B = The number of relevantrecords not retrieved, and  
> C = The number of irrelevant records retrieved.  
> In this example A = 45, B = 35(80-45)and C = 15(60-45)  
> Recall =(45 / (45 + 35)) \* 100% =\> 45/80 \* 100% =56%  
> Precision =(45 / (45 + 15)) \* 100% =\> 45/60 \* 100% =75%
> 
> what would be its relevancy how how ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a3fff8c4-c80b-4b78-9f3b-0ee38dd9b6b5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a3fff8c4-c80b-4b78-9f3b-0ee38dd9b6b5%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [July 6, 2017, 1:52am UTC](https://discuss.elastic.co/t/how-to-calculate-relevancy-by-the-help-of-precision-and-recall/15610/5 "2017-07-06T01:52:30Z")

</div>


