I have constructed my neural network, how can I now use it to predict?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I am building an MLP NN to predict the closing price. The data consists of daily open, close, high and low for the period 1/09/03 - 12/29/17. The training is standard 70% 15% testing 15% validating, whereby the data for the training is all the inputs from 1/09/03 - 1/08/15. The target is the closing price from 2/09/15 - 1/09/15. I want to predict the remaining period from 1/12/15 - 12/29/17 and plot the predicted vs the actual. Also, I am missing many steps can you please assist? I will now present the code for building the network;
[input,PS] = mapminmax(inputs);
[target,TS] = mapminmax(targets);
net = feedforwardnet(20,'trainlm');
net = configure(net,input,target); view(net)
net = init(net);
[net,tr] = train(net,input,target); view(net)
Can you please help me predict and plot, any information will be greatly appreciated.
0 Commenti
Risposte (2)
Vishal Chaudhary
il 13 Ago 2018
For predicting you can use following :
y = net(x); % x contains input data and y is predicted data
If you want to create plot of prediction you can use plot command.
For general NN code see following:
x = input;
t = target;
trainFcn = 'trainlm';
hiddenLayerSize = [10 15 10]; % 3hiddenlayers of with different no. of neurons
net = feedforwardnet(hiddenLayerSize,trainFcn);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
[net,tr] = train(net,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
view(net)
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)
0 Commenti
Saad Ibrahim
il 13 Ago 2018
1 Commento
Vishal Chaudhary
il 13 Ago 2018
For partitioning into train,test,validation I have already mentioned code. If by comparing with actual you mean actual closing price then compute the type of loss you think would be good or visualize it by plotting in same figure.
Vedere anche
Categorie
Scopri di più su Sequence and Numeric Feature Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!