Guest User

Untitled

a guest
Feb 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. def parameter_optimize(x1, x2, y, w1=w1, w2=w2, b=b, learning_rate=learning_rate):
  2. # X contains the 100 student records.
  3. # Iterate through each record.
  4. for i in range(len(x1)):
  5. # Make prediction using the initial values of w1, w2, b.
  6. y_hat = find_perceptron_prediction(x1[i], x2[i], w1, w2, b)
  7. # Case where the red points are wrongly classified.
  8. # This is the case where the actual output is 0 but the prediction is 1.
  9. if y[i] != y_hat and y[i] == 0:
  10. # slowly reduce the parameter values to move the line towards red cluster.
  11. w1 = w1 - test_scores[i] * learning_rate
  12. w2 = w2 - grades[i] * learning_rate
  13. b = b - learning_rate
  14. return w1, w2, b
Add Comment
Please, Sign In to add comment