Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. def distance(features1, features2):
  2. """The Euclidean distance between two arrays of feature values."""
  3. distances = make_array()
  4. for i in range(len(features1)):
  5. dist = (float(features1.item(i)) - float(features2.item(i)))**2
  6. distances = np.append(distances, dist)
  7. return np.sqrt(sum(distances))
  8.  
  9. array1 = np.array(train_movies.row(0))
  10. array2 = np.array(test_movies.row(0))
  11. distance_first_to_first = distance(array1[6::], array2[6::])
  12. distance_first_to_first
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement