#NEWLINE# @ staticmethod #NEWLINE# def randIndex( clustering1 , clustering2 ) : #NEWLINE# #INDENT# '\n        Compute the rand index for 2 clusterings given in arrays v1 and v2.\n        ' #NEWLINE# numVertices = clustering1 . shape [ 0 ] #NEWLINE# error = 0 #NEWLINE# for i in range ( numVertices ) : #NEWLINE# #INDENT# same_cl = ( clustering1 [ i ] == clustering1 ) #NEWLINE# same_learned_cl = ( clustering2 [ i ] == clustering2 ) #NEWLINE# error += ( same_cl != same_learned_cl ) . sum ( ) #NEWLINE# #UNINDENT# return ( float ( error ) / ( numVertices * ( numVertices - 1 ) ) )