Neural Network for Currency Forecast - How do I stop it from repeatedly training after I am happy with my NN performance?

1 view (last 30 days)
I have read a few papers on using a Neural Network to forecast a few periods ahead the price or trend in a Currency pair. I have subsequently designed a simple Neural Network function using NARX. I am passing through a number of times series for different currency pairs and storing the resultatn forecasts. With the code (below), each NN is trained for each currency pair. I would actually prefer to store the NN with optimal performance for each pair. How might I do this? How can I deploy, or keep the optimal NN for each currency pair. That is, I do not want to keep re training each NN for each currency pair time series. Surely I cannot merely comment out this part of the code?
[ neto, tro, Yo, Eo, Xof, Aof ] = train( neto, Xo, To, Xoi, Aoi );
function [ Yo ] = GregNARXf( X,T ) %GREGNARXF Summary of this function goes here
% Subscript "o" for "o"pen loop % Subscript "c" for "c"losed loop % close all, clear all, clc % [ X, T ] = simplenarx_dataset; N = length(T) neto = narxnet; [ Xo, Xoi, Aoi, To ] = preparets( neto, X, {}, T ); to = cell2mat( To ); MSE00o = mean(var(to',1)) % Normalization Reference rng('default') % Added for reproducibility [ neto, tro, Yo, Eo, Xof, Aof ] = train( neto, Xo, To, Xoi, Aoi ); % [ Yo Xof Aof ] = net(Xo,Xoi,Aoi); Eo = gsubtract(To,Yo); NMSEo = mse(Eo)/MSE00o R2o = 1 - NMSEo yo = cell2mat(Yo); figure(1), hold on plot( 3:N, to, 'LineWidth', 2) plot( 3:N, yo, 'ro', 'LineWidth', 2) legend( ' TARGET ', ' OUTPUT ' ) title( ' NARXNET EXAMPLE ' )
TrendYo =cell2mat(Yo(end-10:end));
end

Accepted Answer

Greg Heath
Greg Heath on 19 Aug 2017
Edited: Greg Heath on 19 Aug 2017
{1. The code you have posted is the open loop (OL) solution.
2. It is not a deployable network because it uses the desired
target to generate the output. This is just a step in designing
a deployable network to yield an output that sufficiently
approximates the target when it is deployed with the actual
output being fed back to the input (instead of the desired target).
This is the closed Loop (CL) solution.
3. Accordingly, after you have an acceptable OL solution, you
must close the loop to obtain a deployable network.
4. However, the difference between the desired target and the
actual output often causes the CL solution to have larger than
acceptable errors.
5. Then there are several options
a. Train the newly closed loop net
b. Continue training the OL net
c. Start over with different initial random weights.
d. Start anew with a CL net.
6. There are several MATLAB examples for which I have not been able
to obtain acceptable CL solutions. }
(I haven't given up, just need a summer break (;>) )
Hope this helps.
Thank you for formally accepting my answer
Greg

More Answers (0)

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!