#NEWLINE# def test_NearestNeighborsStrategy( ) : #NEWLINE# #INDENT# model = MatrixPreferenceDataModel ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# strategy = NearestNeighborsStrategy ( ) #NEWLINE# assert_array_equal ( np . array ( [ ] ) , strategy . user_neighborhood ( 'Lorena Abreu' , model ) ) #NEWLINE# model = MatrixPreferenceDataModel ( movies ) #NEWLINE# strategy = NearestNeighborsStrategy ( ) #NEWLINE# assert_array_equal ( np . array ( [ 'Leopoldo Pires' , 'Marcel Caraciolo' , 'Penny Frewman' , 'Sheldom' , 'Steve Gates' , 'Luciana Nunes' ] , dtype = '|S16' ) , strategy . user_neighborhood ( 'Lorena Abreu' , model ) ) #NEWLINE# model = MatrixPreferenceDataModel ( movies ) #NEWLINE# strategy = NearestNeighborsStrategy ( ) #NEWLINE# assert_array_equal ( np . array ( [ 'Leopoldo Pires' , 'Marcel Caraciolo' ] , dtype = '|S16' ) , strategy . user_neighborhood ( user_id = 'Lorena Abreu' , data_model = model , nhood_size = 2 ) ) #NEWLINE# model = MatrixPreferenceDataModel ( movies ) #NEWLINE# strategy = NearestNeighborsStrategy ( ) #NEWLINE# assert_array_equal ( np . array ( [ 'Leopoldo Pires' ] ) , strategy . user_neighborhood ( user_id = 'Lorena Abreu' , data_model = model , minimal_similarity = 0.4 ) ) #NEWLINE# model = MatrixPreferenceDataModel ( movies ) #NEWLINE# strategy = NearestNeighborsStrategy ( ) #NEWLINE# assert_array_equal ( np . array ( [ 'Leopoldo Pires' , 'Steve Gates' , 'Lorena Abreu' , 'Penny Frewman' , 'Sheldom' , 'Luciana Nunes' ] , dtype = '|S14' ) , strategy . user_neighborhood ( 'Marcel Caraciolo' , strategy ) ) #NEWLINE# model = MatrixPreferenceDataModel ( movies ) #NEWLINE# strategy = NearestNeighborsStrategy ( ) #NEWLINE# assert_array_equal ( np . array ( [ ] , dtype = bool ) , strategy . user_neighborhood ( 'Maria Gabriela' , model ) ) #NEWLINE# model = MatrixPreferenceDataModel ( movies ) #NEWLINE# strategy = NearestNeighborsStrategy ( ) #NEWLINE# assert_array_equal ( np . array ( [ ] , dtype = bool ) , strategy . user_neighborhood ( 'Maria Gabriela' , model ) )