www.pudn.com > Kdd-DT-NN.rar > NN.m, change:2016-01-31,size:974b


tic 
clc; 
clear all; 
Train=xlsread('Train.xlsx'); 
Test=xlsread('Test.xlsx'); 
load('index.mat'); 
% index=randperm(32); 
totalMatrix1=Train(:,1:end-1); 
Target1=Train(:,end)'; 
 
totalMatrix2=Test(:,1:end-1); 
Target2=Test(:,end)'; 
 
totalMatrix1=totalMatrix1(:,find(Pos==1)); 
 
totalMatrix2=totalMatrix2(:,find(Pos==1)); 
 
Nclass=3; 
 
trainYG1=zeros(size(totalMatrix1,1),Nclass); 
TestYG1=zeros(size(totalMatrix2,1),Nclass); 
for i=1:1:size(totalMatrix1,1) 
    class=Target1(1,i); 
    trainYG1(i,class)=1; 
end 
 
for i=1:1:size(totalMatrix2,1) 
    class=Target2(1,i); 
    TestYG1(i,class)=1; 
end 
 
trainXT1=totalMatrix1'; 
trainYGT1=trainYG1'; 
 
testXT1=totalMatrix2'; 
testYGT1=TestYG1'; 
 
%% 
net1 = NN_training(trainXT1,trainYGT1,10); 
%net1 = NN_training(trainXT1,trainYGT1,75); 
save('net1','net1'); 
[trainError1] = NN_evaluation(net1,trainXT1,trainYGT1); 
[testError1] = NN_evaluation(net1,testXT1,testYGT1); 
trainError1 
testError1 
nntime1=toc 
%