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
Best Answer