I have constructed my neural network, how can I now use it to predict?
조회 수: 3 (최근 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!