#NEWLINE# @ unittest . skipIf ( ( not ON_REMOTE_NETWORK ) , 'Not in igraph-01 network' ) #NEWLINE# def test_popularity( self ) : #NEWLINE# #INDENT# '\n        Test the popularity okapi algorithm\n        ' #NEWLINE# splitter = RandomSplitter ( ) #NEWLINE# ( training , testing ) = splitter . split ( self . df , 0.2 ) #NEWLINE# pop = Popularity ( normalize = False ) #NEWLINE# pop . fit ( training ) #NEWLINE# self . popularity . fit ( training ) #NEWLINE# for ( _ , row ) in testing . iterrows ( ) : #NEWLINE# #INDENT# assert ( row [ 'user' ] in training [ 'user' ] ) #NEWLINE# python_score = pop . getScore ( row [ 'user' ] , row [ 'item' ] ) #NEWLINE# okapi_score = self . popularity . getScore ( row [ 'user' ] , row [ 'item' ] ) #NEWLINE# assert ( okapi_score == python_score ) , ( "Okapi popularity(%f) don't give the same score as his python implementation(%f)" % ( okapi_score , python_score ) )