def get_ndcg( r, k, method = 1 ):
	dcg_max = dcg_at_k(sorted(r, reverse=True), k, method)
	dcg_min = dcg_at_k(sorted(r), k, method)
	#assert( dcg_max >= dcg_min )
	
	if not dcg_max:
		return 0.
	 
	dcg = dcg_at_k(r, k, method)
	
	#print dcg_min, dcg, dcg_max
	
	return (dcg - dcg_min) / (dcg_max - dcg_min)

# ndcg with explicitly given best and worst possible relevances
# for recommendations including unrated movies
Score is normalized discounted cumulative gain (ndcg)
dataset/ETHPy150Open zygmuntz/evaluating-recommenders/metrics.py/get_ndcg