Multiple Nonlinear Regression Equation using Neural Network Toolbox

7 views (last 30 days)
I am analysing data with six inputs and one output. I had trained a network using Neural Network Toolbox. I want this network to predict the mathematical model or a regression equation. For instance I have six inputs as x1, x2, x3, x4, x5, x6 and one output y. I had trained a network which gives me R=0.999 which seems very good.
Now I want that network provide me an equation in the form.
y= a1*x1^b1 + a2*x2^b2 + a3*x3^b3 + a4*x4^b4 + a5*x5^b5+ a6*x6^b6
How I can get the constants a's and b's.
Regards and thanks in advance.
  1 Comment
Hossein
Hossein on 4 Apr 2014
Dear Zia, Please note that the whole idea of using neural networks, is relevant when you do not know the equation you want to fit on. For instance, you have so many inputs with interrelations. Any you do not know the response behavior. If you have an idea of the equation, it is more than wrong to use neural network. You are better off with the conventional regression methods. Hope that this is helpful.

Sign in to comment.

Accepted Answer

Greg Heath
Greg Heath on 11 Nov 2013
R = 0.999 doesn't mean much unless you can convince us that you did not over-train an over-fit net:
size(x) = [ I N ] % I = 6, N = ?
size(t) = [ O N ] % O =1, N = ?
How was the data divided? Ntrn, Nval, Ntst = ?
Did you use TRAINBR, TRAINLM or TRAINSCG?
Number of training equations Ntrneq = Ntrn*O = ?
How many nodes in the hidden layer? H = ?
Number of unknown weights and biases Nw = {I+1)*H+(H+1)*O = O + (I+O+1)*H = ?
Number of estimation degrees of freedom = Nw - Ntrneq = ?
What are the normalized mean-square errors for the train, val and test subsets? For example,
ttrn = t(trainInd), etc
NMSEtrn = mse(ttrn -ytrn) / var(ttrn,1)
R2trn = 1 - NMSEtrn
Rtrn = sqrt(R2trn)
is Rtst = 0.999?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A neural net is trained on known input/target examples. I do not see any way you can estimate the as and bs with a neural net.
Hope this helps.
Thank you for formally accepting my answer
Greg
  2 Comments
Zia Tahir
Zia Tahir on 11 Nov 2013
Hi Here is my full code.
% Solve an Input-Output Fitting problem with a Neural Network % Script generated by NFTOOL % Created Thu Oct 24 12:14:12 BST 2013 % % This script assumes these variables are defined: % % Li - input data. % Lo - target data.
inputs = Li; targets = Lo;
% Create a Fitting Network
net = feedforwardnet(13, 'trainlm');
% Choose Input and Output Pre/Post-Processing Functions % For a list of all processing functions type: help nnprocess net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'}; net.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% Setup Division of Data for Training, Validation, Testing % For a list of all data division functions type: help nndivide net.divideFcn = 'dividerand'; % Divide data randomly net.divideMode = 'sample'; % Divide up every sample net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100;
% For help on training function 'trainlm' type: help trainlm % For a list of all training functions type: help nntrain net.trainFcn = 'trainlm'; % Levenberg-Marquardt
% Choose a Performance Function % For a list of all performance functions type: help nnperformance net.performFcn = 'mse'; % Mean squared error
% Choose Plot Functions % For a list of all plot functions type: help nnplot net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ... 'plotregression', 'plotfit'};
net.trainParam.epochs=5000 net.trainParam.min_grad=1e-15 net.trainParam.max_fail=2000 net.trainParam.lr=0.01 net.trainParam.mu_max=1e20 % Train the Network [Net21,tr] = train(net,inputs,targets);
% Test the Network outputs = net(inputs); errors = gsubtract(targets,outputs); performance = perform(net,targets,outputs)
% Recalculate Training, Validation and Test Performance trainTargets = targets .* tr.trainMask{1}; valTargets = targets .* tr.valMask{1}; testTargets = targets .* tr.testMask{1}; trainPerformance = perform(net,trainTargets,outputs) valPerformance = perform(net,valTargets,outputs) testPerformance = perform(net,testTargets,outputs)
% To simulate net to get normalized values Sn S=sim(Net21, Li);
%To judge network performace [m, b, r]=postreg(S ,Lo) %To plot percentage error % E=(To-S)*100/To; % plot(E, 'r')
% Plots % Uncomment these lines to enable various plots. %figure, plotperform(tr) %figure, plottrainstate(tr) %figure, plotfit(net,inputs,targets) %figure, plotregression(targets,outputs) %figure, ploterrhist(errors)
Please check it and advise me.
Greg Heath
Greg Heath on 27 Nov 2013
You have wasted a lot of space by specifying values which are already defaults. Type, without the ending semicolon,
net = feedforwardnet
and see what the defaults are. To get an idea of how to use the defaults, see the help and doc examples
help feedforwardnet
doc feedforwardnet
however, these examples are a little too sparse. Check out some of my code by searching on
greg fitnet Ntrials
greg patternnet Ntrials
Hope this helps

Sign in to comment.

More Answers (1)

azie
azie on 27 Nov 2013
u can try 'regress' function.
help regress
by taking your neural network output data as y values.
  1 Comment
Greg Heath
Greg Heath on 23 Aug 2018
BOTTOM LINE:
Your model is a polynomial. Use REGRESS to get the answer.
Trying to use a NN doesn't make much sense, even for practice.
Greg

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!