Attachment 'Aufgabe5.m'

Download

   1 function Aufgabe5
   2 %Aufgabe5 - plot some statistics of USPS dataset: class means, std deviations and outliers. 
   3 %
   4 %usage
   5 %  Aufgabe5
   6 %
   7 %description
   8 %  Aufgabe5 loads the USPS dataset (from usps.mat) and plots 
   9 %   1. the class means;
  10 %   2. the standard deviation of classes 1, 2 and 7; and
  11 %   3. the three datapoints of classes 1, 2, and 7 which are most distant from 
  12 %      the respective class means.
  13 %
  14 %author
  15 %  buenau@cs.tu-berlin.de
  16 
  17 load usps.mat;
  18 
  19 n = size(data_patterns, 2);
  20 
  21 % Plot class means. 
  22 colormap gray;
  23 for i=1:10
  24   subplot(2, 5, i);
  25   imagesc(reshape(mean(data_patterns(:,find(data_labels(i,:) == 1)), 2), [16 16])');  
  26   axis off;
  27   title(sprintf('Mean of class %d', i-1));
  28 end
  29 
  30 figure;
  31 ci = [ 2 3 8 ];
  32 
  33 % Plot standard deviations of classes 1, 2, 7. 
  34 for i=1:length(ci)
  35   subplot(3,1,i);
  36   bar3(reshape(std(data_patterns(:,find(data_labels(ci(i),:) == 1)), [], 2), [16 16])');  axis off;
  37   title(sprintf('Stddev of class %d', ci(i)-1));
  38 end
  39 
  40 % Find and plot outliers of classes 1, 2, 7.
  41 
  42 % Compute squared distance matrix.
  43 xx = sum( data_patterns .^ 2, 1);
  44 D = repmat(xx, [n 1]) -2*data_patterns'*data_patterns + repmat(xx', [1 n]);
  45 
  46 figure;
  47 colormap gray;
  48 
  49 for i=1:length(ci)
  50   c_ii = find(data_labels(ci(i),:) == 1);
  51   m = mean(data_patterns(:,c_ii), 2);
  52   dist = sum( ( data_patterns(:,c_ii) - repmat(m, [1 length(c_ii)]) ) .^ 2, 1 );
  53   [foo, s_ii ] = sort(-dist);
  54 
  55   for j=1:3
  56     subplot(3, 3, sub2ind([3 3], i, j));
  57     imagesc(reshape(data_patterns(:,c_ii(s_ii(j))), [16 16])');
  58     if j == 1, title(sprintf('Outliers of class %d', ci(i)-1)); end
  59   end
  60 end

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-03-12 14:03:20, 1.5 KB) [[attachment:Aufgabe1.m]]
  • [get | view] (2009-03-12 14:03:20, 0.8 KB) [[attachment:Aufgabe2.m]]
  • [get | view] (2009-03-12 14:03:20, 1.0 KB) [[attachment:Aufgabe3.m]]
  • [get | view] (2009-03-12 14:03:20, 1.2 KB) [[attachment:Aufgabe4.m]]
  • [get | view] (2009-03-12 14:03:20, 1.5 KB) [[attachment:Aufgabe5.m]]
  • [get | view] (2009-03-12 14:03:20, 88.7 KB) [[attachment:ML_Praktikum_U01.pdf]]
  • [get | view] (2009-03-12 14:03:20, 89.4 KB) [[attachment:ML_Praktikum_U02.pdf]]
  • [get | view] (2009-03-12 14:03:20, 78.5 KB) [[attachment:ML_Praktikum_U03.pdf]]
  • [get | view] (2009-03-12 14:03:20, 96.2 KB) [[attachment:ML_Praktikum_U04.pdf]]
  • [get | view] (2009-03-12 14:03:20, 74.4 KB) [[attachment:ML_Praktikum_U05.pdf]]
  • [get | view] (2009-03-12 14:03:20, 86.7 KB) [[attachment:ML_Praktikum_U06.pdf]]
  • [get | view] (2009-03-12 14:03:20, 80.0 KB) [[attachment:Matlab_diary.txt]]
  • [get | view] (2009-03-12 14:03:20, 6.3 KB) [[attachment:U03_2gaussians.dat]]
  • [get | view] (2009-03-12 14:03:20, 15.6 KB) [[attachment:U03_5gaussians.dat]]
  • [get | view] (2009-03-12 14:03:20, 1020.4 KB) [[attachment:U04_datasets.zip]]
  • [get | view] (2009-03-12 14:03:20, 6.4 KB) [[attachment:U05_datasets.zip]]
  • [get | view] (2009-03-12 14:03:20, 60.1 KB) [[attachment:fishbowl.mat]]
  • [get | view] (2009-03-12 14:03:20, 22.7 KB) [[attachment:flatroll.mat]]
  • [get | view] (2009-03-12 14:03:20, 22.7 KB) [[attachment:flattroll.mat]]
  • [get | view] (2009-03-12 14:03:20, 343.4 KB) [[attachment:guide.pdf]]
  • [get | view] (2009-03-12 14:03:20, 32.8 KB) [[attachment:long_words.mat]]
  • [get | view] (2009-03-12 14:03:20, 7.6 KB) [[attachment:ratbert-debate.mat]]
  • [get | view] (2009-03-12 14:03:20, 45.3 KB) [[attachment:swissroll.mat]]
  • [get | view] (2009-03-12 14:03:20, 69.4 KB) [[attachment:tu_logo.mat]]
  • [get | view] (2009-03-12 14:03:20, 4053.5 KB) [[attachment:usps.mat]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.