PLOTRESULTS - Plots Figure 2 Example S=ls('result_50_50_20_*.mat','-1'); files=split(S,char(10)); [rs, frac, dim]=plotresults(files); Reference "On the extension of trace norm to tensors" Ryota Tomioka, Kohei Hayashi, and Hisashi Kashima arXiv:1010.0789 http://arxiv.org/abs/1010.0789 Copyright(c) 2010 Ryota Tomioka This software is distributed under the MIT license. See license.txt
0001 % PLOTRESULTS - Plots Figure 2 0002 % 0003 % Example 0004 % S=ls('result_50_50_20_*.mat','-1'); 0005 % files=split(S,char(10)); 0006 % [rs, frac, dim]=plotresults(files); 0007 % 0008 % Reference 0009 % "On the extension of trace norm to tensors" 0010 % Ryota Tomioka, Kohei Hayashi, and Hisashi Kashima 0011 % arXiv:1010.0789 0012 % http://arxiv.org/abs/1010.0789 0013 % 0014 % Copyright(c) 2010 Ryota Tomioka 0015 % This software is distributed under the MIT license. See license.txt 0016 0017 function [rs, frac, dim]=plotresults(files) 0018 0019 ns=length(files); 0020 0021 rs=zeros(ns,3); 0022 frac=zeros(ns,1); 0023 0024 for ii=1:ns 0025 S=load(files{ii}); 0026 sz=S.sz; 0027 rs(ii,:)=S.dtrue; 0028 ix=min(find(mean(S.err)<0.01)); 0029 frac(ii)=S.trfrac(ix); 0030 end 0031 % $$$ 0032 % $$$ figure; 0033 % $$$ plot(sum(rs,2),frac,'x','linewidth',2); 0034 % $$$ for ii=1:ns 0035 % $$$ text(sum(rs(ii,:)),frac(ii),... 0036 % $$$ sprintf('[%d %d %d]',rs(ii,1),rs(ii,2),rs(ii,3))); 0037 % $$$ end 0038 0039 0040 rst = [min(rs(:,1), rs(:,2).*rs(:,3)),... 0041 min(rs(:,2), rs(:,1).*rs(:,3)),... 0042 min(rs(:,3), rs(:,1).*rs(:,2))]; 0043 0044 dim=sum(rst,2); 0045 % figure; 0046 plot(dim,frac,'x','linewidth',2); 0047 for ii=1:ns 0048 text(dim(ii),frac(ii),... 0049 sprintf('[%d %d %d]',rs(ii,1),rs(ii,2),rs(ii,3))); 0050 end 0051 p=polyfit(dim,frac,1) 0052 hold on; 0053 plot(xlim,polyval(p,xlim),'--','color',[.5 .5 .5],'linewidth', 2) 0054 h=get(gca,'children'); 0055 set(gca,'children',h([2:end,1])); 0056 0057 0058 0059 0060 %dim = prod(rs,2)+sum(rs.*(ones(ns,1)*sz),2)-sum(rs.^2,2); 0061 %x = dim.^(1/3); 0062 % $$$ dim(:,1) = max([rst(:,1)*(sz(1)+prod(sz(2:3))) - rst(:,1).^2,... 0063 % $$$ rst(:,2)*(sz(2)+prod(sz([1,3]))) - rst(:,2).^2,... 0064 % $$$ rst(:,3)*(sz(3)+prod(sz(1:2))) - rst(:,3).^2],[],2); 0065 % $$$ 0066 % $$$ dim(:,2) = rst(:,1)*sz(1)+rst(:,2)*sz(2)+rst(:,3)*sz(3); +rst(:,1).*rst(:,2).*rst(:,3)-rst(:,1).^2-rst(:,2).^2-rst(:,3).^2; 0067 % $$$ 0068 % $$$ 0069 % $$$ dim=min(dim,[],2); 0070 % $$$ 0071 % $$$ figure, plot(dim, frac,'x', 'linewidth',2) 0072 % $$$ for ii=1:ns 0073 % $$$ text(dim(ii),frac(ii),... 0074 % $$$ sprintf('[%d %d %d]',rs(ii,1),rs(ii,2),rs(ii,3))); 0075 % $$$ end