confmatplot.html
来自「一个关于数据聚类和模式识别的程序,在生物化学,化学中因该都可以用到.希望对大家有」· HTML 代码 · 共 104 行
HTML
104 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head> <title>Description of confMatPlot</title> <meta name="keywords" content="confMatPlot"> <meta name="description" content="confMatPlot: Display the confusion matrix"> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <meta name="generator" content="m2html © 2003 Guillaume Flandin"> <meta name="robots" content="index, follow"> <link type="text/css" rel="stylesheet" href="../m2html.css"></head><body><a name="_top"></a><div><a href="../index.html">Home</a> > <a href="index.html">dcpr</a> > confMatPlot.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td><td align="right"><a href="index.html">Index for dcpr <img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>confMatPlot</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>confMatPlot: Display the confusion matrix</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>function overall=confMatPlot(confMat, className) </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre class="comment">confMatPlot: Display the confusion matrix
Usage: confMatPlot(confMat, className)
For example:
desired=[1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5];
computed=[1 5 5 1 1 1 1 1 5 5 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 2 5 5 5 5 5 5 5 5 3 5 5 5];
confMat = confMatGet(desired, computed);
className={'Canada', 'China', 'Japan', 'Taiwan', 'US'};
confMatPlot(confMat, className);</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="confMatGet.html" class="code" title="function confMat = confMatGet(desiredOutput, computedOutput)">confMatGet</a> confMatGet: Get confusion matrix from recognition result</li></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="confMatGet.html" class="code" title="function confMat = confMatGet(desiredOutput, computedOutput)">confMatGet</a> confMatGet: Get confusion matrix from recognition result</li></ul><!-- crossreference --><h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><ul style="list-style-image:url(../matlabicon.gif)"><li><a href="#_sub1" class="code">function selfdemo</a></li></ul><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function overall=confMatPlot(confMat, className)</a>0002 <span class="comment">%confMatPlot: Display the confusion matrix</span>0003 <span class="comment">% Usage: confMatPlot(confMat, className)</span>0004 <span class="comment">%</span>0005 <span class="comment">% For example:</span>0006 <span class="comment">% desired=[1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5];</span>0007 <span class="comment">% computed=[1 5 5 1 1 1 1 1 5 5 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 2 5 5 5 5 5 5 5 5 3 5 5 5];</span>0008 <span class="comment">% confMat = confMatGet(desired, computed);</span>0009 <span class="comment">% className={'Canada', 'China', 'Japan', 'Taiwan', 'US'};</span>0010 <span class="comment">% confMatPlot(confMat, className);</span>0011 0012 <span class="comment">% Roger Jang, 20060421, 20070504</span>0013 0014 <span class="keyword">if</span> nargin<1, <a href="#_sub1" class="code" title="subfunction selfdemo">selfdemo</a>; <span class="keyword">return</span>; <span class="keyword">end</span>0015 <span class="keyword">if</span> nargin<20016 <span class="keyword">for</span> i=1:size(confMat, 1)0017 className{i}=int2str(i);0018 <span class="keyword">end</span>0019 <span class="keyword">end</span>0020 0021 <span class="comment">%colordef black;</span>0022 fontSize=10;0023 subplot(1,2,1);0024 str=<span class="string">'Conf. mat. of data counts'</span>;0025 matPlot(confMat, str, <span class="string">'k'</span>, fontSize, <span class="string">'b'</span>, className, className);0026 0027 prob = confMat./(sum(confMat')'*ones(1, size(confMat,1)));0028 overall = sum(diag(confMat))/sum(sum(confMat));0029 new_prob = round(prob*10000)/100;0030 new_overall = round(overall*10000)/100;0031 subplot(1,2,2);0032 str1=<span class="string">'Conf. mat. of recog. rates (%)'</span>;0033 str2=[<span class="string">'Overall recognition rate = '</span>, num2str(new_overall), <span class="string">'%'</span>];0034 matPlot(new_prob, strvcat(str1, str2), <span class="string">'k'</span>, fontSize, <span class="string">'b'</span>, className, className);0035 <span class="comment">% Add the percentage sign</span>0036 <span class="comment">%textH = findobj(gca, 'type', 'text');</span>0037 <span class="comment">%for i=1:length(textH),</span>0038 <span class="comment">% str = get(textH(i), 'string');</span>0039 <span class="comment">% set(textH(i), 'string', [str, '%']);</span>0040 <span class="comment">%end</span>0041 0042 <span class="comment">% ====== Self demo</span>0043 <a name="_sub1" href="#_subfunctions" class="code">function selfdemo</a>0044 desired=[1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5];0045 computed=[1 5 5 1 1 1 1 1 5 5 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 2 5 5 5 5 5 5 5 5 3 5 5 5];0046 confMat = <a href="confMatGet.html" class="code" title="function confMat = confMatGet(desiredOutput, computedOutput)">confMatGet</a>(desired, computed);0047 className={<span class="string">'Canada'</span>, <span class="string">'China'</span>, <span class="string">'Japan'</span>, <span class="string">'Taiwan'</span>, <span class="string">'US'</span>};0048 feval(mfilename, confMat, className);</pre></div><hr><address>Generated on Thu 30-Oct-2008 12:53:56 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?