clear all;
close all;
clear classes;
trainfraction = 1/7;
trainArr = {'Data2004.mat', 'Data2005.mat', 'Data2006.mat', 'Data2007.mat', 'Data2008.mat', 'Data2009.mat', 'Data2010.mat' };
[X_Train,Y_Train,T_Train] = loadData({'Data2003.mat'} , trainfraction);
[X_PredYear,Y_PredYear,T_PredYear] = loadData('Data2011.mat', 0);
input = X_Train';
output = Y_Train';
net1 = feedforwardnet([20 20]);
net1.trainFcn = 'trainscg';
net1.trainParam.max_fail = 100;
net1 = train(net1, input, output);
y = net1(input);
input = X_PredYear';
output = Y_PredYear';
input_test = input;
target_test = output;
predict = sim(net1,input_test);
performance = mse(net1, target_test, predict)
target_test_mean = mean(target_test);
SStot = sum((target_test - target_test_mean).^2);
SSreg = sum((predict - target_test_mean).^2);
SSres = sum((target_test - predict).^2);
Rerr = 1-SSres/SStot
for i = 1:numel(trainArr)
[X_Train,Y_Train,T_Train] = loadData(trainArr(i) , trainfraction);
input = X_Train';
output = Y_Train';
net1 = adapt(net1, input, output);
y = net1(input);
predict = sim(net1,input_test);
performance = perform(net1, target_test, predict)
target_test_mean = mean(target_test);
SStot = sum((target_test - target_test_mean).^2);
SSreg = sum((predict - target_test_mean).^2);
SSres = sum((target_test - predict).^2);
Rerr = 1-SSres/SStot
end