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

📄 adaboost算法中寻找最优阈值分类器的代码优化.htm

📁 AdaBoost算法中寻找最优阈值分类器的代码优化.htm
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0063)http://www.webmastersky.cn/redirect.php?tid=35231&goto=lastpost -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>AdaBoost算法中寻找最优阈值分类器的代码优化 - 网络编程 - 站长天空 站长天空|服务器论坛|站长中国|服务器技术讨论 - Powered by Discuz!</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gbk">
<META 
content=服务器技术,服务器技术讨论,服务器论坛,站长中国,Unauthorized,ftp,iis,iis错误,页面未找到,页面错误,php错误,asp错误,服务未启动,404,408,500,401,403,404,404错误,405,405错误,406,406错误,407,407错误,412,412错误,414,501,501错误,502,502错误,414错误,403错误,401错误,404错误,408错误,500错误, 
name=keywords>
<META 
content=" 站长天空 AdaBoost每一轮的训练获得一个当前权重条件下的最优阈值。&#13;&#10;&#13;&#10;% 逐步求精的方法获取第j个特征值上的最优分类器&#13;&#10;% 输入:&#13;&#10;% X&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;训练样本 ... - Discuz! Board" 
name=description>
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<META content="Discuz! Team and Comsenz UI Team" name=author>
<META content="2001-2007 Comsenz Inc." name=copyright>
<META content=True name=MSSmartTagsPreventParsing>
<META http-equiv=MSThemeCompatible content=Yes><LINK title=站长天空 
href="http://www.webmastersky.cn/archiver/" rel=archives><LINK 
href="AdaBoost算法中寻找最优阈值分类器的代码优化.files/style_1.css" type=text/css 
rel=stylesheet><LINK href="forumdata/cache/style_1_append.css" type=text/css 
rel=stylesheet>
<SCRIPT type=text/javascript>var IMGDIR = 'images/default';var attackevasive = '0';var gid = 0;gid = parseInt('12');var fid = parseInt('14');var tid = parseInt('35231');</SCRIPT>

<SCRIPT src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/common.js" 
type=text/javascript></SCRIPT>

<SCRIPT src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/menu.js" 
type=text/javascript></SCRIPT>

<SCRIPT src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/ajax.js" 
type=text/javascript></SCRIPT>
</HEAD>
<BODY onkeydown="if(event.keyCode==27) return false;">
<DIV id=append_parent></DIV>
<DIV id=ajaxwaitid></DIV>
<DIV class=wrap>
<DIV id=header>
<H2><A title=站长天空 href="http://www.webmastersky.cn/index.php"><IMG alt=站长天空 
src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/logo.gif" border=0></A></H2>
<DIV id=ad_headerbanner></DIV></DIV>
<DIV id=menu>
<UL>
  <LI><A class=notabs href="http://www.webmastersky.cn/register.php">注册</A> 
</LI>
  <LI><A href="http://www.webmastersky.cn/logging.php?action=login">登录</A> </LI>
  <LI><A href="http://www.webmastersky.cn/member.php?action=list">会员</A> </LI>
  <LI><A href="http://www.webmastersky.cn/tag.php">标签</A> </LI>
  <LI><A href="http://www.webmastersky.cn/stats.php">统计</A> </LI>
  <LI><A href="http://www.webmastersky.cn/faq.php">帮助</A> </LI></UL></DIV>
<SCRIPT src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/viewthread.js" 
type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>zoomstatus = parseInt(1);</SCRIPT>

<DIV id=foruminfo>
<DIV id=nav><A href="http://www.webmastersky.cn/index.php">站长天空</A> &raquo; <A 
href="http://www.webmastersky.cn/forumdisplay.php?fid=14">网络编程</A> &raquo; 
AdaBoost算法中寻找最优阈值分类器的代码优化 </DIV>
<DIV id=headsearch></DIV></DIV>
<DIV id=ad_text></DIV>
<DIV class=pages_btns>
<DIV class=threadflow><A 
href="http://www.webmastersky.cn/redirect.php?fid=14&amp;tid=35231&amp;goto=nextoldset">&#8249;&#8249; 
上一主题</A> | <A 
href="http://www.webmastersky.cn/redirect.php?fid=14&amp;tid=35231&amp;goto=nextnewset">下一主题 
&#8250;&#8250;</A></DIV><SPAN class=postbtn id=newspecial 
onmouseover="$('newspecial').id = 'newspecialtmp';this.id = 'newspecial';showMenu(this.id)"><A 
href="http://www.webmastersky.cn/post.php?action=newthread&amp;fid=14&amp;extra="><IMG 
title=发新话题 alt=发新话题 src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/newtopic.gif" 
border=0></A></SPAN> <SPAN class=replybtn><A 
href="http://www.webmastersky.cn/post.php?action=reply&amp;fid=14&amp;tid=35231&amp;extra="><IMG 
alt="" src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/reply.gif" 
border=0></A></SPAN></DIV>
<UL class="popupmenu_popup newspecialmenu" id=newspecial_menu 
style="DISPLAY: none">
  <LI><A 
  href="http://www.webmastersky.cn/post.php?action=newthread&amp;fid=14&amp;extra=">发新话题</A> 
  </LI>
  <LI class=poll><A 
  href="http://www.webmastersky.cn/post.php?action=newthread&amp;fid=14&amp;extra=&amp;special=1">发布投票</A> 
  </LI>
  <LI class=trade><A 
  href="http://www.webmastersky.cn/post.php?action=newthread&amp;fid=14&amp;extra=&amp;special=2">发布商品</A> 
  </LI>
  <LI class=reward><A 
  href="http://www.webmastersky.cn/post.php?action=newthread&amp;fid=14&amp;extra=&amp;special=3">发布悬赏</A> 
  </LI>
  <LI class=activity><A 
  href="http://www.webmastersky.cn/post.php?action=newthread&amp;fid=14&amp;extra=&amp;special=4">发布活动</A> 
  </LI>
  <LI class=debate><A 
  href="http://www.webmastersky.cn/post.php?action=newthread&amp;fid=14&amp;extra=&amp;special=5">发布辩论</A> 
  </LI>
  <LI class=video><A 
  href="http://www.webmastersky.cn/post.php?action=newthread&amp;fid=14&amp;extra=&amp;special=6">发布视频</A> 
  </LI></UL>
<FORM name=modactions method=post><INPUT type=hidden value=c46296f3 
name=formhash> 
<DIV class="mainbox viewthread"><SPAN class=headactions><A class=notabs 
href="http://www.webmastersky.cn/viewthread.php?action=printable&amp;tid=35231" 
target=_blank>打印</A> </SPAN>
<H1>AdaBoost算法中寻找最优阈值分类器的代码优化 </H1>
<TABLE id=pid47019 cellSpacing=0 cellPadding=0 summary=pid47019>
  <TBODY>
  <TR>
    <TD class=postauthor><CITE><A class=dropmenu id=userinfo47019 
      onmouseover=showMenu(this.id) 
      href="http://www.webmastersky.cn/space.php?uid=3851" 
      target=_blank>micky</A></CITE> 
      <DIV class=avatar><IMG height=90 alt="" 
      src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/20.gif" width=90 border=0></DIV>
      <P><EM>管理员</EM></P>
      <P><IMG alt="Rank: 9" 
      src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/star_level3.gif"><IMG alt="Rank: 9" 
      src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/star_level3.gif"><IMG alt="Rank: 9" 
      src="AdaBoost算法中寻找最优阈值分类器的代码优化.files/star_level1.gif"></P>
      <UL>
        <LI class=pm><A id=ajax_uid_47019 
        onclick="ajaxmenu(event, this.id, 9000000, null, 0)" 
        href="http://www.webmastersky.cn/pm.php?action=send&amp;uid=3851" 
        target=_blank>发短消息</A> </LI>
        <LI class=buddy><A id=ajax_buddy_0 
        onclick="ajaxmenu(event, this.id, null, 0)" 
        href="http://www.webmastersky.cn/my.php?item=buddylist&amp;newbuddyid=3851&amp;buddysubmit=yes" 
        target=_blank>加为好友</A> </LI>
        <LI class=offline>当前离线 </LI></UL></TD>
    <TD class=postcontent>
      <DIV class=postinfo><STRONG id=postnum_47019 title=复制帖子链接到剪贴板 
      onclick="setcopy('http://www.webmastersky.cn/viewthread.php?tid=35231&amp;page=1#pid47019', '帖子链接已经复制到剪贴板')">1<SUP>#</SUP></STRONG> 
      <EM onclick="$('postmessage_47019').className='t_bigfont'">大</EM> <EM 
      onclick="$('postmessage_47019').className='t_msgfont'">中</EM> <EM 
      onclick="$('postmessage_47019').className='t_smallfont'">小</EM> 发表于 
      2007-11-7 17:19&nbsp; <A 
      href="http://www.webmastersky.cn/viewthread.php?tid=35231&amp;page=1&amp;authorid=3851">只看该作者</A> 
      </DIV>
      <DIV id=ad_thread2_0></DIV>
      <DIV class="postmessage defaultpost">
      <DIV id=ad_thread3_0></DIV>
      <DIV id=ad_thread4_0></DIV>
      <H2>AdaBoost算法中寻找最优阈值分类器的代码优化</H2>
      <DIV class=t_msgfont 
      id=postmessage_47019>AdaBoost每一轮的训练获得一个当前权重条件下的最优阈值。<BR><BR>% 
      逐步求精的方法获取第j个特征值上的最优分类器<BR>% 输入:<BR>% X&nbsp; &nbsp;&nbsp; &nbsp;训练样本,rows 
      X cols 维矩阵,rows个样本,每个样本cols个特征值<BR>% Y&nbsp; &nbsp;&nbsp; 
      &nbsp;每个样本所属类别的标识,向量,长度为rows<BR>% rows&nbsp; &nbsp;样本容量 <BR>% weight 
      权重向量,存放当前每个样本的权重值<BR>% j&nbsp; &nbsp;&nbsp; &nbsp; 当前查找最佳弱分类器的特征列<BR>% 
      输出:<BR>%&nbsp;&nbsp;bestError&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;%搜索到第j列最佳弱分类器得到的最小错误率<BR>%&nbsp;&nbsp;bestThresh&nbsp; 
      &nbsp;%搜索到第j列最佳弱分类器的阈值<BR>%&nbsp;&nbsp;bestBias&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;%搜索到第j列最佳弱分类器的偏置<BR>% <BR>% 迭代4次,每次将区间划分为12个小段<BR>%<BR>% 
      调用格式为 [bestError,bestThresh,bestBias]=findBestWeakLearner(X,Y,rows,weight,j)<BR>% 
      最后更新 2007-03-25 <BR>function 
      [bestError,bestThresh,bestBias]=findBestWeakLearner(X,Y,rows,weight,j)<BR>% 
      检查输入特征向量与类标需为列向量<BR>iptcheckinput(X,{'logical','numeric'},{'2d','nonempty','real'},mfilename, 
      'X', 
      1);<BR>iptcheckinput(Y,{'logical','numeric'},{'column','nonempty','integer'},mfilename, 
      'Y', 2);<BR><BR>iteration=4;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; % 迭代次数<BR>sectNum=12;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;% 
      每次迭代,将搜索区域划分的片段<BR>maxFea=max(X(:,j));&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;% 搜索空间的最大值 
      <BR>minFea=min(X(:,j));&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; % 
      搜索空间的最小值<BR>step=(maxFea-minFea)/(sectNum-1);&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;% 每次搜索的递增量<BR><BR>bestError=rows;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; % 初值:最好的分类器错误率<BR>for 
      iter=1:iteration&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; % 
      迭代iteration次,范围逐步缩小,寻找最优值<BR>&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;tempError=rows;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;% 初值:第iter次迭代的分类器错误率&nbsp; 
      &nbsp;&nbsp; &nbsp;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;for 
      i=1:sectNum&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;% 第iter次迭代的搜索次数<BR>&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;thresh=minFea+(i-1)*step;&nbsp; &nbsp; % 
      第i次搜索的阈值<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;for 
      p=1:-2:-1&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; % !这个循环可去掉<BR>&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; h=zeros(rows,1);&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;%每个样本对弱分类器的输出<BR>&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; for ii=1:rows&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;%!这个循环可向量化<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;if((p*X(ii,j))&lt;(p*thresh))<BR>&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;h(ii)=1;<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;else<BR>&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;h(ii)=0;<BR>&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;end<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp; end %end for<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; error=sum(weight(find(h~=Y))); % 
      第iter次迭代第i次搜索加权错误率<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp; <BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; %! 这段属冗余代码<BR>&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if(error&lt;tempError)&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;% 第iter次迭代最优的错误率 阈值 
      偏置<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tempError=error;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp; % 第iter次迭代最小的错误率<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;tempThresh=thresh;&nbsp; &nbsp;% 
      第iter次迭代最小错误分类情况下的阈值<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tempBias=p;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;% 
      第iter次迭代最小错误分类情况下的偏置<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp; end<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; 
      &nbsp;end%end for p<BR>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;end%end for 
      i<BR>&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp;&nbsp;if(tempError&lt;bestError)&nbsp; &nbsp;&nbsp; 
      &nbsp;&nbsp; &nbsp; %&nbsp;&nbsp;迭代获取的最优错误率 阈值 偏置<BR>&nbsp; &nbsp;&nbsp; 

⌨️ 快捷键说明

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