How do you compute MAP in python for evaluating recommender system effectiveness? Is there any library in sklearn or code in python for it?

I would like to compute the effectiveness of my Recommender System by computing Mean Average Precision.


This library called Metrics provides most of metrics for Machine Learning including MAP for Recommendation systems. If you only interested in metrics for recommendation systems, perhaps you can see this library.

  • $\begingroup$ Can i get proper implementation with python code.I am not able to get any references for it? $\endgroup$ – SARTHAK Jan 30 at 7:17
  • $\begingroup$ That library I recommended has all python implementation, what do you mean? have you checked those github pages? Click on "Metrics", or 'this library" and you see. $\endgroup$ – TwinPenguins Jan 30 at 16:58

You can use the ml_metrics library. For install this library use:

pip install ml_metrics

import ml_metrics 

ml_metrics.mapk(actual, predicted, k)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.