diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-05-11 11:49:42 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-05-11 11:49:42 +0200 |
commit | 0f6d90832f1c436a804f847c769a28b544995812 (patch) | |
tree | 7e5000f56cff7ab1f37e68449a5f0d9474acdfb7 | |
parent | 4925b295bffdcba7db7d4be9a6f7b5b20b107068 (diff) | |
download | dmc-0f6d90832f1c436a804f847c769a28b544995812.tar.gz dmc-0f6d90832f1c436a804f847c769a28b544995812.tar.bz2 dmc-0f6d90832f1c436a804f847c769a28b544995812.zip |
run_tests: Use an vector of structs for the prediction methods
Allows use to use e.g. pred_methods.name.
-rw-r--r-- | run_tests.m | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/run_tests.m b/run_tests.m index 57cb722..da1f7d9 100644 --- a/run_tests.m +++ b/run_tests.m @@ -6,26 +6,26 @@ train_data = q( 1:28, :); real_data = q(29:42, :); -pred_methods = { - { 'mean', @mean_pred }, - { 'regress', @regress_pred }, - { 'quad', @quad_regress_pred }, - { 'log reg.', @log_regress_pred }, - { 'sevenday' @sevenday_pred }, - { 'random' @rand_pred }, - { 'regress2' @regress_frequency_removal } -}; +pred_methods = [ + struct('name', 'mean', 'func', @mean_pred ) + struct('name', 'regress', 'func', @regress_pred ) + struct('name', 'quad', 'func', @quad_regress_pred ) + struct('name', 'log reg.', 'func', @log_regress_pred ) + struct('name', 'sevenday', 'func', @sevenday_pred ) + struct('name', 'random', 'func', @rand_pred ) + struct('name', 'regress2', 'func', @regress_frequency_removal ) +]; num_methods = size(pred_methods, 1); pred_list = {}; for i = 1:num_methods - pred_list{i} = pred_methods{i}{2}(p, train_data); + pred_list{i} = pred_methods(i).func(p, train_data); end qerr = terr = zeros(1, num_methods); err = zeros(num_methods, size(real_data,2)); for i = 1:num_methods - [qerr(i), terr(i), err(i, :)] = calc_error(pred_methods{i}{1}, real_data, pred_list{i}); + [qerr(i), terr(i), err(i, :)] = calc_error(pred_methods(i).name, real_data, pred_list{i}); end opt_data = opt_pred(real_data, pred_list); |