% Vorlesung Machine Learning and Data Mining
% Lösung zu Blatt 1-3
% Martin Wunderlich
% 11007857

printf("============================\n")
printf("1-3 - Perceptron-Lernregel\n")
printf("============================\n")

	% Initalize data 
	printf("Initializing...\n")
	% Patterns with bias
	p1 = [1;2;4]
	p2 = [1;1;0.5]
	p3 = [1;0.5;1.5]
	p4 = [1;0;0.5]

	A = zeros(2:3)';
	B = zeros(2:3)';
	A(:,1) = p1;
	A(:,2) = p2;
	B(:,1) = p3;
	B(:,2) = p4;

	% Input matrix with all training samples: 
	P = [A';B']'

	% Correct training results
	labelA = 1;
	labelB = -1;
	Y = [labelA;labelA;labelB;labelB]

	% Parameters
	W = [0;1;-1]	% initial weight vector
	printf("Initializing...DONE\n")

eta = 0.1;
runTraining(P, Y, W, eta);
eta = 0.25;
runTraining(P, Y, W, eta);

printf("==== DONE =====\n")
