ginitest.m

来自「the matlab code of ginisvm - an svm impl」· M 代码 · 共 48 行

M
48
字号
function [rateval,znorm] = ginitest(inpvec,gamma);%------------------------------------------------% This function implements the gini normalization% procedure by finding a threshold using the% reverse water-filling procedure.%% inpvec -> Unnormalized inputs.% gamma  -> Normalization Factor.% rateval-> Probability vector.% znorm  -> threshold factor.%------------------------------------------------[L,M] = size(inpvec);rateval = zeros(1,M);znorm = 0;if gamma > 0,   [fthd,ind] = sort(inpvec);   target = gamma;   zt = 0;   curr = M;   while zt < target & curr >= 2,       zt = sum(fthd(curr:M) - fthd(curr-1));       curr = curr - 1;   end;   if curr == 1,       if zt < target,       % Means we have to include the total classes            znorm = 1/M*(sum(fthd(curr:M)) - target);            for class = curr:M,                  rateval(ind(class)) = ((inpvec(ind(class)) - znorm));            end;        else            znorm = 1/(M-1)*(sum(fthd(2:M)) - target);            for class = curr+1:M,               rateval(ind(class)) = ((inpvec(ind(class)) - znorm));            end;        end;    else        znorm = 1/(M-curr)*(sum(fthd(curr+1:M)) - target);        for class = curr+1:M,            rateval(ind(class)) = ((inpvec(ind(class)) - znorm));        end;    end;end;

⌨️ 快捷键说明

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