Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
leili
committed
Oct 7, 2009
1 parent
9d7a564
commit 5fcb786
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |