I have constructed my neural network, how can I now use it to predict?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Vishal Chaudhary
2018-8-13
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 个评论
Saad Ibrahim
2018-8-13
1 个评论
Vishal Chaudhary
2018-8-13
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!