compute_wmw.m

来自「RankNGG 算法实现. 含有dll文件。源码为matlab」· M 代码 · 共 84 行

M
84
字号
function [WMW]=compute_WMW(data,o,enough_memory)
% Computes the Generalized Wilcoxon-Mann-Whitney Statistic.
%
%% Input
%
% * data ... structure containing the data regarding the ranking task at hand [See convert_data_to_ranking_format.m]
% * o ... vector containing the output of the ranking function
% * enough_memory .. if 1 uses the matrix version of the code else resorts to for loops
%
%  Basic information---
%
% * data.N ... number of data points
% * data.d ... data dimensionality
% * data.S ... number of classes
% * data.m ... number of inputs in each class
%
%  Actual data---
%
% * data.labels ... vector of class labels
% * data.X ... cell array where each cell contains the data belonging to one class
% * data.index ... index of the data belonging to one class
% * data.X_raw ... d x N original data matrix
% * data.y_raw ... 1 x N vector of the class labels
%
%  Preference graph---
%
% * data.graph_type ... graph type
% * data.C ... number of edges in the preference graph
% * data.G ... data.C x 2 matrix encoding the preference relations. The class in the second column is preferred over that in the first column.
% * data.num_of_pairs ... total number of pairwise preference realtions

%
%% Ouput
%
% * WMW ... Generalized Wilcoxon-Mann-Whitney Statistic
%
%% Signature
%
% Author: Vikas Chandrakant Raykar
% E-Mail: vikas@cs.umd.edu
% Date: September 20, 2006
%
%% See also
%
% convert_data_to_ranking_format
%

if data.num_of_pairs >0

    num=0.0;

    for g=1:data.C
        % Index j is prefered over index i
        i=data.G(g,1);
        j=data.G(g,2);

        if enough_memory==1
            fi=repmat(o(data.index{i})',1,data.m(j));
            fj=repmat(o(data.index{j}),data.m(i),1);
            num=num+length(find((fi-fj)<=0));
        end
        if enough_memory==0
            for k=1:data.m(i)
                for l=1:data.m(j)
                    fi=o(data.index{i}(k));
                    fj=o(data.index{j}(l));
                    if fj >= fi
                        num=num+1.0;
                    end
                end
            end
        end
    end

    WMW=num/data.num_of_pairs;

else

    WMW=1;

end


return

⌨️ 快捷键说明

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