⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 som_stats_report.m

📁 竞争学习的matlab工具箱
💻 M
字号:
function som_stats_report(csS,fname,fmt,texonly)% SOM_STATS_REPORT Make report of the statistics.%  % som_stats_report(csS, fname, fmt, [standalone])%%  som_stats_report(csS, 'data_stats', 'ps')%%  Input and output arguments ([]'s are optional): %   csS          (cell array) of statistics structs%                (struct) a statistics struct%   fname        (string) output file name (without extension)%                (cellstr) {direc, fname}%   fmt          (string) report format: 'ps', 'pdf', 'html' or 'txt'%   [texonly]    (any)    for 'ps' and 'pdf' formats: if 4th argument %                         is given, only the tex file is written %                         (w/o document start/end), and it is not compiled%% See also  SOM_STATS, SOM_STATS_PLOT, SOM_STATS_TABLE, SOM_TABLE_PRINT, REP_UTILS.% Contributed to SOM Toolbox 2.0, December 31st, 2001 by Juha Vesanto% Copyright (c) by Juha Vesanto% http://www.cis.hut.fi/projects/somtoolbox/% Version 2.0beta juuso 311201%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% input argumentsif isstruct(csS), csS = {csS}; enddim = length(csS);if iscell(fname), direc = fname{1}; fname = fname{2}; else direc = '.'; endif nargin<4, texonly = 0; else texonly = 1; end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% action% additional analysiscontinuity = zeros(dim,1);for i=1:dim, continuity(i) = csS{i}.nunique / csS{i}.nvalid; endentropy_rel = zeros(dim,1);for i=1:dim,     c = csS{i}.hist.counts;     if length(c) < 2 | all(c==0), entropy(i) = 0;     else        maxent = log(length(c));        c = c(c>0)/sum(c);        entropy_rel(i) = -sum(c.*log(c)) / maxent;    end end% meta-statisticsvalues  = {'Number of variables',dim; ...           'Number of samples',csS{1}.ntotal; ...           'Valid values',c_and_p_str(count_total(csS,'nvalid'),dim*csS{1}.ntotal); ...           'Mean(#unique / #valid)',mean(continuity); ...           'Mean relative entropy',mean(entropy_rel)};           %'Dataset name',sD.name; 'Report generated',datestr(now);          sTdset = som_table_struct(values);% statistics tables[sTstats,csThist] = som_stats_table(csS); sTstats = som_table_modify(sTstats,'addcol',entropy_rel,{'entropy'});% write reportif isempty(fname), fid = 1; else     switch fmt,    case {'ps','pdf'}, ending = '.tex';     case 'html', ending = '.html';     case 'txt', ending = '.txt';     end     fid = fopen([direc '/' fname ending],'w'); endif ~texonly, rep_utils('header',fmt,fid); endrep_utils({'inserttable',sTdset,1,0},fmt,fid);rep_utils({'insertbreak'},fmt,fid);rep_utils({'inserttable',sTstats,1,0},fmt,fid);rep_utils({'insertbreak'},fmt,fid);som_stats_plot(csS,'stats'); rep_utils({'printfigure',[direc '/histograms']},fmt);rep_utils({'insertfigure','histograms'},fmt,fid);for i=1:dim,     rep_utils({'insertbreak'},fmt,fid);    rep_utils({'inserttable',csThist{i},1,0},fmt,fid);end if ~texonly, rep_utils('footer',fmt,fid); endif fid~=1, fclose(fid); endif ~texonly & any(strcmp(fmt,{'ps','pdf'})), rep_utils('compile',fmt); endreturn;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subfunctionsfunction a = count_total(csS,field)  % count total of the field values  a = 0; for i=1:length(csS), a = a + getfield(csS{i},field); end  return;  function str = c_and_p_str(n,m)  % return a string of form # (%), e.g. '23 (12%)'  if n==m, p = '100';   elseif n==0, p = '0';  else p = sprintf('%.2g',100*n/m);  end  str = sprintf('%d (%s%%)',round(n),p);   return;  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -