#NEWLINE# def GetCosSimilarityForGenres( user_film , dataset_film ) : #NEWLINE# #INDENT# ( v1_2 , v2_2 , v1_x_v2 ) = ( 0 , 0 , 0 ) #NEWLINE# for i in range ( len ( user_film ) ) : #NEWLINE# #INDENT# v1_2 += ( int ( user_film [ i ] ) * int ( user_film [ i ] ) ) #NEWLINE# v2_2 += ( dataset_film [ i ] * dataset_film [ i ] ) #NEWLINE# v1_x_v2 += ( int ( user_film [ i ] ) * dataset_film [ i ] ) #NEWLINE# #UNINDENT# sim = ( v1_x_v2 / ( math . sqrt ( v1_x_v2 ) * math . sqrt ( v2_2 ) ) ) #NEWLINE# return sim