fisheriris データにパーセプトロン アルゴリズムを適用したいのですが、このコードを試してみました
function [  ] = Per(  )
%PERCEPTON_NN Summary of this function goes here
%   Detailed explanation goes here
%%%%%%%%%%%STEP ONE INPUT DATA PREPERATION
%N=3000;
load fisheriris
tr=50; %traning
te=50; %test
epochs =150;
data=meas;
%N = size(meas,1);
%species=nonomil(species)
%figure,plot(data_shuffeled(1,:),data_shuffeled(2,:),'rx');
%%%%%%%%%%%%%%%%%%%STEP TWO INTIALIZE  WEIGHT
baise=1;
w=[baise; 1 ; 1;1 ; 1];
eta=0.9; %%learning rate
%%%%%%%%%%%%%%%%%%%%%%%% Rosen Blatt learning Algo
for epoch=1 : epochs 
for i=1 : tr
   x=[1;data(i,1);data(i,2);data(i,3);data(i,4)]; % input vector
   N = size(species,i); %desiard output
   y=w'*x; % y=actual output ,w'= transpose w , mmoken y=w.*x 
   %%%%%%%%%%%%%%% Activation function (hardlimit)(step fn)
   y=1*(y>=0)+(-1)*(y<0); % da badl el if 
   %%%%%%%%%%% Error calcualtion %%%%%%%
   err(i)=N-y;
   %%%%%%%%%%%%%% update weight %%%%%%%%%5
   wnew=w+ eta*err(i)*x;
   w=wnew;
end
mse(epoch)=mean(err.^2);
end
%%%%%%%%%%%%%%%%%%%%%%  step four classification (testing) %%%%%%%%%%%%%%%%%%5
hold on
for i=1 : te
    %x=[1;data(i,1);data(i,2),data(i,3);data(i,4)];
     x=[1;data(i,1);data(i,2);data(i,3);data(i,4)]; 
   % d=data_shuffeled(3,i+tr);
    N = size(species,i);
    y=w'*x;
    y=1*(y>=0)+(-1)*(y<0);
    if (y==1)
        plot(x(2),x(3),x(4),x(5),'rx');
    elseif y==-1
        plot(x(2),x(3),x(4),x(5),'r&');
    end
end
hold off
 if abs(N-y)>1E-6
    testerro=testerro+1;
end
私はこのコードを書いて、fisheririsデータの「測定」を入力として、種を「出力」としてパーセプトロンアルゴリズムを作成しました
コードのヘルプまたはこのコードの変更。
ありがとう 。