【模式识别】Learning To Rank之RankBoost

RankBoost的思想比較简单,是二元Learning to rank的常规思路:通过构造目标分类器,使得pair之间的对象存在相对大小关系。通俗点说,把对象组成一对对的pair,比方一组排序r1>r2>r3>r4,那能够构成pair:(r1,r2)(r1,r3),(r1,r4),(r2,r3)(r3,r4),这种pair是正值,也就是label是1。而余下的pair如(r2,r1)的值应该是-1或0。这样一个排序问题就被巧妙的转换为了分类问题。近来CV界许多又用这种learning to rank的思想做识别问题(最早应该是这篇《Person Re-Identification by Support Vector Ranking》),也就是把识别转换为排序问题再转换为分类问题。

Pairwise的排序方法主要用RankSVM和RankBoost,这里主要说RankBoost,总体还是一个Boost的框架:


注意其与常规Boost的不同组要是Update的时候。当然数据分布也不同。这里能够看出对于终于的排序值。也就是ranking score。其值是没有实际意义的,相对的顺序才有意义。比方r1和r2终于得分是10分和1分。与r1,r2终于得分是100分和1分的信息量区别并不大,我们能得到的结论都是r1应该排在r2前面。

因为和传统的Boost目标不一样。求解也须要很巧妙的方法,主要在于定义分类器的Loss函数:


详细的,因为以及我们能够得到分布D的损失:


于是,目标就变成了最小化


至此,传统的Boost线性搜索策略已经能够求解,但还有更巧妙的办法。因为函数:

于是,对于所以[-1 1]范围内的x。Z能够近似为:


当中。这样直接能够Z最小时。此时。于是被转换为最大化|r|的问题。

下面是一段RankBoost的代码:

function [ rbf ] = RankBoost( X,Y,D,T )
%RankBoost implemetation of RankBoost algoritm
%   Input:
%       X - train set.
%       Y - train labels.
%       D - distribution function over X times X, it the form of 2D matrix.
%       T - number of iteration of the boosting.
%   Output:
%       rbf - Ranking Function.

rbf = RankBoostFunc(T);
% w - the current distribution in any iteration, initilize to D
w = D;
for t=1:T
    tic;
    fprintf('RankBoost: creating the function, iteration %d out of %d
',t,T);
    WL = getBestWeakLearner(X,Y,w);
    rbf.addWeakLearner(WL,t);
    rbf.addAlpha(WL.alpha,t);
    alpha=WL.alpha;
    
    %update the distribution
    %eval the weak learnler on the set of X and Y
    h=WL.eval(X);
    [hlen, ~] = size(h);
    tmph = (repmat(h,1,hlen) - repmat(h',hlen,1));
    w=w.*exp(tmph.*alpha);
    %normalize w
    w = w./sum(w(:));
    toc;
end
end

一个比較明显的问题是RankBoost须要维持一个很大的|X|*|X|的矩阵。程序执行十分占内存,常常抛出“Out of memory”的错误。

所以诸如

tmph = (repmat(h,1,hlen) - repmat(h',hlen,1));
之类的操作不如换成例如以下方式:

   % tmph = (repmat(h,1,hlen) - repmat(h',hlen,1));
    %w=w.*exp(tmph.*alpha);
    [rows, cols] = size(w);
    sumw = 0;
    for r=1:rows
        for c=1:cols
            w(r,c) = w(r,c)*exp((h(r)-h(c))*alpha);
            sumw = sumw + w(r,c);
        end
    end
    
    %normalize w
    %w = w./sum(w(:));
    w = w./sumw;




(转载请注明作者和出处:http://blog.csdn.net/xiaowei_cqu 未经同意请勿用于商业用途)


原文地址:https://www.cnblogs.com/blfshiye/p/5268426.html