Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
leili committed Oct 7, 2009
1 parent 9d7a564 commit 5fcb786
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
21 changes: 21 additions & 0 deletions runall_compress_dynammo.m
@@ -0,0 +1,21 @@
function [error_dynammo_all, ratio_dynammo_all, h_dynammo_all] = runall_compress_dynammo(X, varargin)
% try many different hidden dimensions and get the compression ratio and
% errors using dynammo compression with dynamic programming.
% the resulting ratio is sorted descently, and the error is drawn from
% skyline shape.
% see compress_dynammo.m for additional arguments

error_dynammo_all = [];
ratio_dynammo_all = [];
h_dynammo_all = [];
cands = [1 : 4, 5:5:size(X, 1)];
for HIDDEN = cands
[error, ratio] = compress_dynammo(X, 'Hidden', HIDDEN, varargin{:});
apsize = length(error);
error_dynammo_all = [error_dynammo_all, error];
ratio_dynammo_all = [ratio_dynammo_all, ratio];
h_dynammo_all = [h_dynammo_all, repmat(HIDDEN, 1, apsize)];
fprintf('Hidden = %d, error = %d, ratio = %d\n', HIDDEN, error(1), ratio(1));
end
[ratio_dynammo_all, tmpIdx] = sort(ratio_dynammo_all, 'descend');
error_dynammo_all = cummin(error_dynammo_all(tmpIdx)); % get the skyline plot
20 changes: 20 additions & 0 deletions test_compress_dynammo_chlorine.m
@@ -0,0 +1,20 @@
% test fingerprint_compress on chlorine dataset
clear;
data = load('chlorine_level_data_cl2fullLarge.dat');
X = data';
tic;
[error_dynammo_all, ratio_dynammo_all, h_dynammo_all] = runall_compress_dynammo(X, 'MaxIter', 50, 'RelativeError', 'method', 'optimal');
time_dynammo = toc;

tic;
[error_ad_all, ratio_ad_all, h_ad_all] = runall_compress_dynammo(X, 'MaxIter', 50, 'RelativeError', 'method', 'adaptive');
time_ad = toc;

[error_svd_all, ratio_svd_all, h_svd_all] = compress_pca(X);

h = figure;
hold on;
plot(ratio_svd_all, error_svd_all, 'b', 'LineWidth', 2, 'DisplayName', 'PCA');
plot(ratio_ad_all, error_ad_all, 'g', 'LineWidth', 2, 'DisplayName', 'DynaMMo_a');
plot(ratio_dynammo_all, error_dynammo_all, 'r', 'LineWidth', 2, 'DisplayName', 'DynaMMo_d');
legend show;

0 comments on commit 5fcb786

Please sign in to comment.