I have constructed my neural network, how can I now use it to predict?
2 ビュー (過去 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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!