From: Shireen on 26 Oct 2006 06:32 Dear all, I am new to ANN and I am trying to run ANN to obtain a regression equation for some data. I use the same script for the same data but the strange thing is that whenever I run the script, I obtain different results ( I mean different correlation coeeficient as well as different error value). I am wondering why is this? Also, which output should I trust? Is there is any crieteria to decide? Any help would be appreciated. The script I use is the following: ..................................................... %parallel copy for NNSAMPLE Sample Training Session close all clear all % Load in the data file input = xlsread('HSA_descr-outliers19.xls'); %Principal component analysis: [pc, score, latent, tsquare] = princomp(input); %p is input and t is target input=input(:,1:20); input=input'; t=input(1,:); p=input(2:20,:); % Normalize the inputs and targets so that they have % zero mean and unity variance. [pn,meanp,stdp,tn,meant,stdt] = prestd(p,t); % Perform a principal component analysis and remove those % components which account for less than 0.1% of the %variation. [ptrans,transMat] = prepca(pn,0.001); % Divide the data up into training, validation and test sets. % The testing set will start with the second point and take % every fourth point. The validation set will start with the % fifth point and take every fifth point. The training set % will take the remaining points. [R,Q] = size(ptrans) test.P = ptrans(:,[2,3,23,26,33,36,40,48,50,66,68,69,70,71,76,88]); test.T = tn(:,[2,3,23,26,33,36,40,48,50,66,68,69,70,71,76,88]); val.P = ptrans(:,[1,6,22,25,32,35,46,47,55,57,64,65,72,74,75,85]); val.T = tn(:,[1,6,22,25,32,35,46,47,55,57,64,65,72,74,75,85]); ptr = ptrans(:,[4,5,7,8,9,10,11,12,16,17,18,21,24,27,28,29,30,31,34,37,38,39 ,41,42,43,44,45,49,51,52,53,54,56,58,59,60,62,63,67,73,77,78,79,80,81, 82,83,84,86,87,89,91,92]); ttr = tn(:,[4,5,7,8,9,10,11,12,16,17,18,21,24,27,28,29,30,31,34,37,38,39,41, 42,43,44,45,49,51,52,53,54,56,58,59,60,62,63,67,73,77,78,79,80,81,82,8 3,84,86,87,89,91,92]); % DEFINING THE NETWORK % ==================== net = newff(minmax(p),[4 1]{'tansig' 'purelin'},'trainbr'); % TRAINING THE NETWORK net = init(net); [net,tr]=train(net,p,t); % Simulate the trained network. an = sim(net,p); %an = sim(net,ptrans); % Convert the output of the network back into the original units of the targets. a = poststd(an,meant,stdt); % We will now display plots showing regression analyses %between the network outputs and the corresponding target %(in original units). figure [m,b,r] = postreg(a,t); %end of file
From: oleam on 26 Oct 2006 08:55 Shireen wrote: > > > Dear all, > I am new to ANN and I am trying to run ANN to obtain a regression > equation for some data. I use the same script for the same data but > the strange thing is that whenever I run the script, I obtain > different results ( I mean different correlation coeeficient as > well > as different error value). I am wondering why is this? Also, which > output should I trust? Is there is any crieteria to decide? > > Any help would be appreciated. > > The script I use is the following: > .................................................... > %parallel copy for NNSAMPLE Sample Training Session > > close all > clear all > > % Load in the data file > input = xlsread('HSA_descr-outliers19.xls'); > > %Principal component analysis: > [pc, score, latent, tsquare] = princomp(input); > > %p is input and t is target > input=input(:,1:20); > input=input'; > t=input(1,:); > p=input(2:20,:); > > % Normalize the inputs and targets so that they have > % zero mean and unity variance. > [pn,meanp,stdp,tn,meant,stdt] = prestd(p,t); > > % Perform a principal component analysis and remove those > % components which account for less than 0.1% of the > %variation. > [ptrans,transMat] = prepca(pn,0.001); > > % Divide the data up into training, validation and test sets. > % The testing set will start with the second point and take > % every fourth point. The validation set will start with the > % fifth point and take every fifth point. The training set > % will take the remaining points. > [R,Q] = size(ptrans) > test.P = ptrans(:,[2,3,23,26,33,36,40,48,50,66,68,69,70,71,76,88]); > test.T = tn(:,[2,3,23,26,33,36,40,48,50,66,68,69,70,71,76,88]); > val.P = ptrans(:,[1,6,22,25,32,35,46,47,55,57,64,65,72,74,75,85]); > val.T = tn(:,[1,6,22,25,32,35,46,47,55,57,64,65,72,74,75,85]); > ptr = > ptrans(:,[4,5,7,8,9,10,11,12,16,17,18,21,24,27,28,29,30,31,34,37,38, > 39 > ,41,42,43,44,45,49,51,52,53,54,56,58,59,60,62,63,67,73,77,78,79,80,8 > 1, > 82,83,84,86,87,89,91,92]); > ttr = > tn(:,[4,5,7,8,9,10,11,12,16,17,18,21,24,27,28,29,30,31,34,37,38,39,4 > 1, > 42,43,44,45,49,51,52,53,54,56,58,59,60,62,63,67,73,77,78,79,80,81,82 > ,8 > 3,84,86,87,89,91,92]); > > % DEFINING THE NETWORK > % ==================== > > net = newff(minmax(p),[4 1]{'tansig' 'purelin'},'trainbr'); > > % TRAINING THE NETWORK > net = init(net); > [net,tr]=train(net,p,t); > % Simulate the trained network. > an = sim(net,p); > %an = sim(net,ptrans); > > % Convert the output of the network back into the original units of > the targets. > a = poststd(an,meant,stdt); > > % We will now display plots showing regression analyses > %between the network outputs and the corresponding target > %(in original units). > > figure > [m,b,r] = postreg(a,t); > %end of file I basically have the same problem. well in my case the training is pretty stable --though i get some variation in the trained networks. the problem is that when i used those differently trained networks i get very different results. if you search for "oleam" you can find my post + 1 answer hope this helps and sorry that i cannot help you further, oleam
From: Steven Lord on 26 Oct 2006 09:24 "Shireen" <shireen.alfalah(a)yahoo.com> wrote in message news:ef44959.-1(a)webcrossing.raydaftYaTP... > Dear all, > I am new to ANN and I am trying to run ANN to obtain a regression > equation for some data. I use the same script for the same data but > the strange thing is that whenever I run the script, I obtain > different results ( I mean different correlation coeeficient as well > as different error value). I am wondering why is this? Also, which > output should I trust? Is there is any crieteria to decide? *snip* > % DEFINING THE NETWORK > % ==================== > > net = newff(minmax(p),[4 1]{'tansig' 'purelin'},'trainbr'); > > % TRAINING THE NETWORK > net = init(net); At this point, the weights and biases contain random initial values. If you want to repeat the regression exactly, you need to initialize the random number generators to the same value before this line. rand('twister', 12345); % or rand('state', 12345) if you're using a version of MATLAB that doesn't include the Mersenne Twister randn('state', 67890); You can replace 12345 and 67890 with whatever values you want. *snip* -- Steve Lord slord(a)mathworks.com
From: Shireen on 26 Oct 2006 14:02 Dears Steven and Oleam, Thank you very much for your kind replies. Dear all, As it was kindly suggested, I managed to have the same regression results by using the command "randn('state', 67890);". But I obtained a worse regression results than the ones I obtained before. Of course I prefere the way that gives better regression results but I am still wondering if the old results I obtained before are correct or no. My question can be divided into two parts: 1) Why I obtained a better regression results after many runs for the netwrok? Is it part of training process ? Or is it some missleading "good looking" results? 2) What are the best parameters and functions that fits well with regression purpose? Any help would be very appreciated. Best wishes, Shireen Steven Lord wrote: > > > > "Shireen" <shireen.alfalah(a)yahoo.com> wrote in message > news:ef44959.-1(a)webcrossing.raydaftYaTP... >> Dear all, >> I am new to ANN and I am trying to run ANN to obtain a regression >> equation for some data. I use the same script for the same data > but >> the strange thing is that whenever I run the script, I obtain >> different results ( I mean different correlation coeeficient as > well >> as different error value). I am wondering why is this? Also, > which >> output should I trust? Is there is any crieteria to decide? > > *snip* > >> % DEFINING THE NETWORK >> % ==================== >> >> net = newff(minmax(p),[4 1]{'tansig' 'purelin'},'trainbr'); >> >> % TRAINING THE NETWORK >> net = init(net); > > At this point, the weights and biases contain random initial > values. If you > want to repeat the regression exactly, you need to initialize the > random > number generators to the same value before this line. > > > rand('twister', 12345); % or rand('state', 12345) if you're using a > version > of MATLAB that doesn't include the Mersenne Twister > randn('state', 67890); > > > You can replace 12345 and 67890 with whatever values you want. > > *snip* > > -- > Steve Lord > slord(a)mathworks.com > > >
|
Pages: 1 Prev: Java problem on Solaris when matlab run as user Next: Repeated Measures MANOVA |