PageRenderTime 29ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/code_oth/disperror.m

http://research-code-base-animesh.googlecode.com/
MATLAB | 91 lines | 53 code | 9 blank | 29 comment | 15 complexity | 4294977ae0df0303b5a1c03fe20a2bb6 MD5 | raw file
  1. %DISPERROR Display error matrix with information on classifiers and datasets
  2. %
  3. % DISPERROR(DATA,CLASSF,ERROR,STD,FID)
  4. %
  5. % INPUT
  6. % DATA Cell array of M datasets or dataset names (strings)
  7. % CLASSF Cell array of N mappings or mapping names (strings)
  8. % ERROR M*N matrix of (average) error estimates
  9. % STD M*N matrix of standard devations on ERROR (optional)
  10. % FID File in which results are written (default: 1)
  11. % OUTPUT
  12. %
  13. % DESCRIPTION
  14. % Displays the matrix ERROR matrix with error estimates for N
  15. % classifiers related to M datasets. This routine is called by TESTC
  16. % and CROSVALL to display results.
  17. %
  18. % EXAMPLE
  19. % testsets = {gendath gendatb gendatd(100,5)}
  20. % trainsets = {gendath gendatb gendatd(100,5)}
  21. % classifiers = {nmc fisherc qdc svc}
  22. % testc(testsets,map(trainsets,classifiers))
  23. %
  24. % SEE ALSO
  25. % MAPPINGS, DATASETS, TESTC, CROSSVAL
  26. % $Id: disperror.m,v 1.7 2004/10/04 15:43:10 duin Exp $
  27. function disperror (data,classf,err,stdev,fid)
  28. if nargin < 5, fid = 1; end
  29. % Check arguments.
  30. if (nargin > 3) & (any(size(err) ~= size(stdev)))
  31. error('size of matrix with standard deviations should match matrix with errors')
  32. end
  33. if (~iscell(classf)) | (~isstr(classf{1}) & ~ismapping(classf{1}))
  34. error('cell array of mappings or mapping names expected')
  35. end
  36. if (~iscell(data)) | (~isstr(data{1}) & ~isdataset(data{1}))
  37. error('cell array of datasets or datasets names expected')
  38. end
  39. [m,n] = size(err);
  40. if (length(data) ~= m)
  41. error('size of dataset cell array should equal number of rows in error matrix');
  42. end
  43. if (length(classf) ~= n)
  44. error('size of classifier cell array should equal number of columns in error matrix');
  45. end
  46. % If datasets are supplied, extract their names.
  47. for j = 1:m
  48. if (isdataset(data{j}))
  49. data{j} = getname(data{j},20);
  50. end
  51. end
  52. % If classifiers are supplied, extract their names.
  53. for j = 1:n
  54. if (ismapping(classf{j}))
  55. classf{j} = getname(classf{j});
  56. end
  57. end
  58. if (n == 1)
  59. fprintf(fid,' %s \n\n',classf{1});
  60. else
  61. fprintf(fid,'\n');
  62. for i = 1:n
  63. fprintf(fid,'\n clsf_%i : %s',i,classf{i});
  64. end
  65. fprintf(fid,'\n\n ');
  66. for i = 1:n
  67. fprintf(fid,' clsf_%i',i);
  68. end
  69. fprintf(fid,'\n\n');
  70. end
  71. for j = 1:m
  72. fprintf(fid,' %s',data{j});
  73. fprintf(fid,' %7.3f',err(j,:));
  74. if (nargin > 3)
  75. fprintf(fid,'\n ');
  76. fprintf(fid,' %7.3f',stdev(j,:));
  77. fprintf(fid,'\n');
  78. end
  79. fprintf(fid,'\n');
  80. end
  81. fprintf(fid,'\n');
  82. return