public static double L_RankLoss(int y[],int r[]){
  int L=y.length;
  ArrayList<Integer> tI=new ArrayList<Integer>();
  ArrayList<Integer> fI=new ArrayList<Integer>();
  for (int j=0; j < L; j++) {
    if (y[j] == 1) {
      tI.add(j);
    }
 else {
      fI.add(j);
    }
  }
  if (!tI.isEmpty() && !fI.isEmpty()) {
    int c=0;
    for (    int k : tI) {
      for (      int l : fI) {
        if (position(k,r) < position(l,r)) {
          c++;
        }
      }
    }
    return (double)c / (double)(tI.size() * fI.size());
  }
 else {
    return 0.0;
  }
}

public static double L_RankLoss ( int y [ ] , int r [ ] ) { int L = y . length ; ArrayList < Integer > tI = new ArrayList < Integer > ( ) ; ArrayList < Integer > fI = new ArrayList < Integer > ( ) ; for ( int j = 0 ; j < L ; j ++ ) { if ( y [ j ] == 1 ) { tI . add ( j ) ; } else { fI . add ( j ) ; } } if ( ! tI . isEmpty ( ) && ! fI . isEmpty ( ) ) { int c = 0 ; for ( int k : tI ) { for ( int l : fI ) { if ( position ( k , r ) < position ( l , r ) ) { c ++ ; } } } return ( double ) c / ( double ) ( tI . size ( ) * fI . size ( ) ) ; } else { return 0.0 ; } }
rank loss - the average fraction of labels which are not correctly ordered . thanks to noureddine yacine nair benrekia for providing bug fix for this .
