question: public static double P_AveragePrecision ( int y [ ] , int r [ ] ) { double avg_prec = 0 ; int L = y . length ; List < Integer > ones = new ArrayList < Integer > ( ) ; for ( int j = 0 ; j < L ; j ++ ) { if ( y [ j ] == 1 ) { ones . add ( j ) ; } } if ( ones . size ( ) <= 0 ) return 1.0 ; for ( int j : ones ) { double s = 0.0 ; for ( int k : ones ) { if ( r [ k ] <= r [ j ] ) { s ++ ; } } avg_prec += ( s / ( 1. + r [ j ] ) ) ; } avg_prec /= ones . size ( ) ; return avg_prec ; }
target:  Average Precision - computes for each relevant label the percentage of relevant labels among all labels that are ranked before it.