Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parameter_optimize(x1, x2, y, w1=w1, w2=w2, b=b, learning_rate=learning_rate):
- # X contains the 100 student records.
- # Iterate through each record.
- for i in range(len(x1)):
- # Make prediction using the initial values of w1, w2, b.
- y_hat = find_perceptron_prediction(x1[i], x2[i], w1, w2, b)
- # Case where the red points are wrongly classified.
- # This is the case where the actual output is 0 but the prediction is 1.
- if y[i] != y_hat and y[i] == 0:
- # slowly reduce the parameter values to move the line towards red cluster.
- w1 = w1 - test_scores[i] * learning_rate
- w2 = w2 - grades[i] * learning_rate
- b = b - learning_rate
- return w1, w2, b
Add Comment
Please, Sign In to add comment