Quote:
Originally Posted by zsero
I've written the algorithm just based on the lecture and it worked. Here is the "core" of the algorithm (written in Python / Numpy):
Code:
w = np.zeros( 3 )
done = False
while not done:
wrongpoints = 0
for p in points:
if np.sign( np.dot(w, p) ) != targetFunction( p ):
w = np.add( w, targetFunction( p ) * p )
wrongpoints += 1
break
if wrongpoints == 0:
done = True
If anyone is interested in the Python implementation, here is my full code with plotting:
https://gist.github.com/2395395
and the one for the experiments:
https://gist.github.com/2395409

Argh! I am new to Python and did not know about numpy. It looks so much more concise than my code that has all the vector multiplication and what not. One thing I noticed is that you keep adding to weights for each wrongpoint whereas Yaser had mentioned to adjust it only once per iteration.
Correction: My bad! Missed the 'break' statement