Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Your code goes here
- # 5 for training 5 for testing
- def face_prediction(samples):
- # split the data
- training_samples, testing_samples= partition_data(labels,num_per_class=5)
- # split testing and traing samples to get X and Y
- training_data_X, training_data_Y = split_left_right(data[training_samples])
- testing_data_X, testing_data_Y = split_left_right(data[testing_samples])
- # train the model
- w = l2_rls_train(training_data_X,training_data_Y,0)
- # make predictions
- predictions = l2_rls_predict(w,testing_data_X)
- # join the predicted faces together
- faces = join_left_right(testing_data_X, predictions)
- # join the test faces together for comparing
- real_faces = join_left_right(testing_data_X, testing_data_Y)
- print(np.size(predictions))
- print(np.abs(testing_data_Y- predictions))
- errors = np.sum(np.abs(testing_data_Y - predictions)) * 100 / (255 * np.size(predictions))
- print(errors)
- # show both sets of faces
- show_faces(faces[20:30, :], num_per_row=5)
- show_faces(real_faces[20:30, :], num_per_row=5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement