#NEWLINE# def get_ndcg_2( r , best_r , worst_r , k , method = 1 ) : #NEWLINE# #INDENT# dcg_max = dcg_at_k ( sorted ( best_r , reverse = True ) , k , method ) #NEWLINE# if ( worst_r == None ) : #NEWLINE# #INDENT# dcg_min = 0.0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dcg_min = dcg_at_k ( sorted ( worst_r ) , k , method ) #NEWLINE# #UNINDENT# if ( not dcg_max ) : #NEWLINE# #INDENT# return 0.0 #NEWLINE# #UNINDENT# dcg = dcg_at_k ( r , k , method ) #NEWLINE# return ( ( dcg - dcg_min ) / ( dcg_max - dcg_min ) )