Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. # Your code goes here
  2. # 5 for training 5 for testing
  3. def face_prediction(samples):
  4. # split the data
  5. training_samples, testing_samples= partition_data(labels,num_per_class=5)
  6.  
  7. # split testing and traing samples to get X and Y
  8. training_data_X, training_data_Y = split_left_right(data[training_samples])
  9. testing_data_X, testing_data_Y = split_left_right(data[testing_samples])
  10.  
  11. # train the model
  12. w = l2_rls_train(training_data_X,training_data_Y,0)
  13.  
  14. # make predictions
  15. predictions = l2_rls_predict(w,testing_data_X)
  16.  
  17. # join the predicted faces together
  18. faces = join_left_right(testing_data_X, predictions)
  19.  
  20. # join the test faces together for comparing
  21. real_faces = join_left_right(testing_data_X, testing_data_Y)
  22.  
  23. print(np.size(predictions))
  24. print(np.abs(testing_data_Y- predictions))
  25. errors = np.sum(np.abs(testing_data_Y - predictions)) * 100 / (255 * np.size(predictions))
  26. print(errors)
  27. # show both sets of faces
  28. show_faces(faces[20:30, :], num_per_row=5)
  29. show_faces(real_faces[20:30, :], num_per_row=5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement