I cant seem to figure out why I have a high percentage error.
I'm trying to get a perceptron between X1 and X2 which are Gaussian distributed data sets with distinct means and identical co-variances.
Below is my code:
N=200; C= [2 1; 1 2]; %Covariance m1=[0 2]; m2=[1.5 0];%mean X1 = mvnrnd(m1, C, N/2); X2 = mvnrnd(m2, C, N/2); X = [X1; X2]; X = [X ones(N,1)]; %bias y = [-1*ones(N/2,1); ones(N/2,1)]; %classification %Split data into training and test ii = randperm(N); Xtr = X(ii(1:N/2),:); ytr = X(ii(1:N/2),:); Xts = X(ii(N/2+1:N),:); yts = y(ii(N/2+1:N),:); Nts = N/2; w = randn(3,1); eta = 0.001; %learn from training set for iter=1:500 j = ceil(rand*N/2); if( ytr(j)*Xtr(j,:)*w < 0) w = w + eta*Xtr(j,:)'; end end %apply what you have learnt to test set yhts = Xts * w; disp([yts yhts]) PercentageError = 100*sum(yts .*yhts < 0)/Nts;
What am I doing wrong and how can I address this challenge?