I am working on a recommender system where i need to calculate similarity in ratings for user friends. which one out of cosine similarity and pearson correlation is better approach?
The selection of the similarity function for CF recommendations depends on the associated recommendation domain and task. In fact, an very important paper in RS research like
"A Survey of Accuracy Evaluation Metrics of Recommendation Tasks", Journal of Machine Learning Research 10 (2009) 2935-2962
shows that pearson or cosine can perform as the best alternative, according to the recommendation task.
Recently there have been new researches focused on proposing new similarity functions in CF, that you can check and finally choose according to your requirements. Some of them are:
Choi, K., & Suh, Y. (2013). A new similarity function for selecting neighbors for each target item in collaborative filtering. Knowledge-Based Systems, 37, 146-153.
Liu, H., Hu, Z., Mian, A., Tian, H., & Zhu, X. (2014). A new user similarity model to improve the accuracy of collaborative filtering. Knowledge-Based Systems, 56, 156-166.
Bobadilla, J., Ortega, F., Hernando, A., & Glez-de-Rivera, G. (2013). A similarity metric designed to speed up, using hardware, the recommender systems k-nearest neighbors algorithm. Knowledge-Based Systems, 51, 27-34.
You can also check this paper for a further discussion on similarity calculation in CFRS:
Lathia, N., Hailes, S., & Capra, L. (2008, March). The effect of correlation coefficients on communities of recommenders. In Proceedings of the 2008 ACM symposium on Applied computing (pp. 2000-2005). ACM.