% neural_simple_class.m	09/15/99
% express using of neural network for classification
% last no_class columns correspond to classes!! (so, they probably contain only zeros and ones)

function [pred, net, train_record]=neural_simple_class(trn,val,tst,info)

s=size(trn);
block=[trn;val];
hidd=info.hidd;
no_class=info.no_class;
net=newff([min(block(:,1:s(2)-no_class));max(block(:,1:s(2)-no_class))]',[hidd no_class],{'tansig','logsig'},'trainrp');
%net=newff([min(block(:,1:s(2)-no_class));max(block(:,1:s(2)-no_class))]',[hidd no_class],{'tansig','purelin'},'trainrp');

VV.P=val(:,1:s(2)-no_class)';
VV.T=val(:,s(2)-no_class+1:s(2))';
if ~isempty(tst)
   TV.P=tst(:,1:s(2)-no_class)';
   TV.T=tst(:,s(2)-no_class+1:s(2))';
   else
    TV=[];
end
net.trainParam.epochs = info.epochs;
net.trainParam.show = info.show;
net.trainParam.max_fail=info.max_fail;
net.trainParam.showWindow = info.showWindow;
[net, train_record] = train(net,trn(:,1:s(2)-no_class)',trn(:,s(2)-no_class+1:s(2))',[],[],VV,TV);

disp(['Training finished at: ' mat2str(clock)]);

if isempty(tst)==0
   pred = sim(net,tst(:,1:s(2)-no_class)')';
else
   pred=[];
end

return;
