NARNET FOR BINARY CLASSIFICATION PREDICTION
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mario Viola
am 19 Feb. 2021
Kommentiert: Mario Viola
am 24 Feb. 2021
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!
0 Kommentare
Akzeptierte Antwort
Jack Xiao
am 21 Feb. 2021
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!