I am trying to build a graph of precision and recall using click data. I have two data sources.
- First data source has all the user clicked item_ids based on a given query_id.
- Second data source has all the relevant item_ids for given query_id.
I used python and put these in two data sources into dictionaries as follows:
>>> print clicked_data
{101: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 103: [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]}
>>> print all_relevant_data
{101: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], 103: [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]}
I was reading the article in scikit-learn web site (http://scikit-learn.org/stable/auto_examples/plot_precision_recall.html) and tried to follow the formula but got really confuse really setting up False Positive and False Negative.
following the equations in scikit-learn: According to above example prevision for item 101
P = T_positive/ (T_positive + F_positive)
>>> float(len(clicked_data[101]))/float(len(all_relevant_data[101]))
0.5555555555555556
But as I try to figure out Recall I am having trouble in getting False Negative items of click data. In theory False Negative means incorrectly marked. All I have is user clicked data for a given id and all the items that are relevant to that id.
R = T_positive / (T_positive + F_negative)
How can I calculate precision and recall correctly so I can build a graph.
On a different note if this is not a good metric to evaluate the results, considering the fact that I only have above mention data what would be the good metric?