import math


def LOO_check(ranking_list, target_item, topk=10):
	"""Calculate three ranking metrics: HR, NDCG, MRR

	Parameters
	----------
	ranking_list : 1-D array
		a recommender's prediction result
	target_item : int
		ground-truth item
	topk : int, optional
		by default 10

	Returns
	-------
	HR, NDCG, MRR: float, float, float
	"""
	k = 0
	for item_id in ranking_list:
		if k == topk: return (0., 0., 0.)
		if target_item == item_id: return (1., math.log(2.) / math.log(k + 2.), 1.0 / (k + 1.))
		k += 1