⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sgnt.m

📁 ISGNN是对SGNN(self-generated neural network)的一种改进,是一种在线学习的算法.
💻 M
字号:
close all
clear all
delta= 0.4;

%  iris data set: Input dimmension M=4;  Output dimmension: N=3
%  Wisconsine Brests Cencer data set: Input dimmension M=9;  Output dimmension: N=1
%  taxdata data set: Input dimmension M=71;  Output dimmension: N=1

M=4;
N=3;
%********************************************
load iris_tr
iris= IRIS_training_data;
[nr,nc]=size(iris);
clear IRIS_training_data

%load taxdata
%[nr,nc]= size(tax);
%wis= tax;

%load wine_a
%Y=wine_a;
%clear wine_a

%load wisconsine
%[nr,nc]=size(Y);
%for i=1:1:nc-1   iris(:,i)= Y(:,i);  end

ii=floor(nr/2);
for i=1:1:ii                    Y(i,:)=iris(i,:);    end
for i=ii+1:1:nr                 S(i-ii,:)= iris(i,:);   end
%clear iris_tr  iris

[nr,nc]=size(Y);

%********************************************************
% training process
%***********************************************************
tic;CPUTIME=cputime;
%************************************************
nodeY= sgnt_generating_online(Y,M+N);
%*******************************************************
TOC=toc;
CPUTIME=cputime-CPUTIME 

%*********************************************************
% test process
%*********************************************************
%load iris_te 
%S = IRIS_testing_data;
%clear IRIS_testing_data

%load wine_b
%S=wine_b;
%clear wine_b
[sr,sc]=size(S);

tic;CPUTIME=cputime;

[nr,nc]= size(nodeY);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Err=0;
i5=1;
for j=1:1:sr
   dmin= inf;
   for i=1:1:nr
      if nodeY(i,M+N+2) > 0
         for k=1:1:M  
             w(k)= nodeY(i,k);
             ss(k)= S(j,k);
         end
         d= (ss-w)*(ss-w)';
         if dmin > d   
            dmin= d;
            min= i;
         end
      end
   end
   
   for k=1:1:N
      x1(k)= S(j,M+k);
      x2(k)= nodeY(min,M+k);
   end
   ds= sqrt((x1-x2)*(x1-x2)');
   if ds > delta  
       Err= Err+1; 
       c(i5)=j;  
       i5=i5+1; 
   end
end

accuracy= (1-(Err/sr))*100   
Err=Err
TOC=toc;
CPUTIME2= cputime-CPUTIME 
   
   
   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -