필터 지우기
필터 지우기

NARNET FOR BINARY CLASSIFICATION PREDICTION

조회 수: 2 (최근 30일)
Mario Viola
Mario Viola 2021년 2월 19일
댓글: Mario Viola 2021년 2월 24일
Hi all, i am trying to implement a NARNET for predicting next day return direction (either up or down). In all the examples i saw, the prediction is made on the exact value of the time series cosnidered. However, i would like to simply get the positive or negative difference between two consecutive closing prices (in terms of 1 & 0, for example). I tried with simpler networks, such as patternnet or feedforward net, but the performance was very poor. With the NARNET and its delays feature, i thought it would be a more suitable netwrok for this kind of predictions. I will attach the code i wrote so far.
StockData = readtable('MSFT.csv');
Close = StockData.Close;
Date = StockData.Date;
T = timetable(Date,Close);
if any(any(ismissing(T.Close)))== 1
T = fillmissing(T,'linear');
end
r = NaN(size(T.Close,1),1);
r(2:end) = T.Close(2:end) ./ T.Close(1:end-1) - 1;
nextDayReturn = double(r(2:end) > 0);
nextDayReturn(nextDayReturn==0)=-1;
F = tonndata(nextDayReturn,false,false);
trainFcn = 'trainlm';
feedbackDelays = 1:5;
hiddenLayerSize = [10 10];
net = narnet(feedbackDelays,hiddenLayerSize,'open',trainFcn);
[x,xi,ai,t] = preparets(net,{},{},F);
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.performFcn = 'mse';
net.trainParam.epochs = 15000;
net.trainParam.goal = 1e-15;
net.trainParam.min_grad = 1e-40;
net.trainParam.max_fail = 100;
[net tr] = train(net,x,t,xi,ai);
y = net(x,xi,ai);
e = gsubtract(t,y);
performance = perform(net,t,y);
Another idea i had was to train the networks on the Closing Prices Series, and when predicting the values of the Prices, Calculating the difference of consecutive prices and setting it equal to 1 if positive or 0 otherwise. I need it coded in terms of 1 and 0 (or -1 eventually) for implementing a trading strategy based on these kind of signals.
Hope i was clear in the explanation, and hope you could help me in finding a solution. Any kind of suggestions or improvements on the kind of analysis i'm trying to implement would be appreciated as well. I'm Kinda Stuck!

채택된 답변

Jack Xiao
Jack Xiao 2021년 2월 21일
you can refer the given demo for classification, in fact the given net in the demo can be applicative. the key is that you should prepare your trainding data carefully, the paried input and output (1 or 0) should be processed beforehand.
  댓글 수: 1
Mario Viola
Mario Viola 2021년 2월 24일
Thank you for your answer! Could you please attach the demo you are reffering to, i am not sure to which one you are reffering.
I just would like to know if i can sonehow combine a NARNET and a PATTERNET, meaning for example using the latter one but with a delayed set of inputs, in order to better capture the patterns in the financial series.
This refers also to the processing of inputs and outputs, as i should pair the return (output) in one day (1 or 0), with a series of inputs (for ex. not only returns in previous day, but also technical indicators and other variables). I know this refers to the NARXNET architecture, but i just wanted to know if, theoretically, something like this could be implemented.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by