Exercise 1.4

Answers

Implement the perceptron learning algorithm and check

  • Convergence speed:
    The convergence is fast, it depends on the data, but usually, it only takes about 10 iterations to find a solution.
  • How well the final hypothesis g matches your target f:
    The final hypothesis g doesn’t match my target f very closely in terms of their coefficients. But from the picture, they are largely in line with each other in the range of data.
#perceptron(df.values, 2) 
 
lb, ub = -100100 
N, dim = 202 
num_grid_points = 2000 
coeff_lb, coeff_ub = -1010 
eta = 1 
maxit = 100 
use_adaline, randomize = FalseFalse 
_, _, _ = run_perceptron_experiment(N, dim, lb, ub, 
                             num_grid_points, 
                             coeff_lb, coeff_ub, 
                             eta, maxit, use_adaline, randomize)
final correctness:  20 . Total iteration:  2
final normalized w: [0.02354535 0.26266196 1.        ]
True coeffs:  [2.16057234 0.3672496  1.        ]

PIC

User profile picture
2021-12-07 18:06
Comments