diff options
author | Jan Klemkow <j.klemkow@wemelug.de> | 2012-05-12 11:03:34 +0200 |
---|---|---|
committer | Jan Klemkow <j.klemkow@wemelug.de> | 2012-05-12 11:03:34 +0200 |
commit | c877d4871fea3826afc192bfb5efe0b42b53b130 (patch) | |
tree | af77fb738b5307a51f1694642df65aca9b38f117 | |
parent | a8eb5eb83fb762630c83a765967313f4ccb59493 (diff) | |
download | dmc-c877d4871fea3826afc192bfb5efe0b42b53b130.tar.gz dmc-c877d4871fea3826afc192bfb5efe0b42b53b130.tar.bz2 dmc-c877d4871fea3826afc192bfb5efe0b42b53b130.zip |
opt_pred: Split opt_pred in opt_idx and opt_pred.
So you can use the idx of opt_idx for other predictions.
-rw-r--r-- | opt_idx.m | 10 | ||||
-rw-r--r-- | opt_pred.m | 11 | ||||
-rw-r--r-- | run_tests.m | 3 |
3 files changed, 14 insertions, 10 deletions
diff --git a/opt_idx.m b/opt_idx.m new file mode 100644 index 0000000..76864c8 --- /dev/null +++ b/opt_idx.m @@ -0,0 +1,10 @@ +function idx = opt_idx(real_data, pred_list) + + err_list = zeros(size(pred_list, 2), size(real_data, 2)); + + for i = 1:size(pred_list, 2) + err_list(i,:) = sum(abs(real_data - pred_list{i})); + end + + [min_err, idx] = min(err_list); +end @@ -1,13 +1,6 @@ -function pred = opt_pred(real_data, pred_list) +function pred = opt_pred(idx, pred_list) - err_list = zeros(size(pred_list, 2), size(real_data, 2)); - - for i = 1:size(pred_list, 2) - err_list(i,:) = sum(abs(real_data - pred_list{i})); - end - - [min_err, idx] = min(err_list); - pred = zeros(size(real_data)); + pred = zeros(size(pred_list{1})); for i = 1:size(idx, 2) pred(:,i) = pred_list{idx(i)}(:,i); diff --git a/run_tests.m b/run_tests.m index 12306a4..87b16e7 100644 --- a/run_tests.m +++ b/run_tests.m @@ -30,7 +30,8 @@ for i = 1:num_methods [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); +method_idx = opt_idx(real_data, pred_list); +opt_data = opt_pred(method_idx, pred_list); [qerr(end+1), terr(end+1), opt_err] = calc_error('optimize', real_data, opt_data); %bar(qerr); |