用于特征选择的最小冗余最大相关度(MRMR)

时间:2017-01-09 03:49:00

标签: matlab

我在特征选择中使用称为(MRMR)最小冗余最大相关性的过滤器度量。我运行下面的代码后

function testselection

    addpath('C:\Users\Desktop\mRMR_0.9_compiled\mi_0.9');
FeaturesFile = dlmread('test.txt')
[x,y]=size(FeaturesFile)
Features=FeaturesFile(:,1:y-1)

classLeble=FeaturesFile(:,y)

[fea] = mrmr_mid_d(Features, classLeble, 5)

end

我收到以下错误

Undefined function or variable 'estpab'.

Error in mutualinfo (line 21)
[p12, p1, p2] = estpab(vec1,vec2);

Error in mrmr_mid_d (line 17)
   t(i) = mutualinfo(d(:,i), f);

Error in mrmr (line 9)
[fea] = mrmr_mid_d(Features, classLeble, 5);

mrmr_mid_d的代码如下

function [fea] = mrmr_mid_d(d, f, K)
% function [fea] = mrmr_mid_d(d, f, K)
% 
% MID scheme according to MRMR
%
% By Hanchuan Peng
% April 16, 2003
%

bdisp=0;

nd = size(d,2);
nc = size(d,1);

t1=cputime;
for i=1:nd, 
   t(i) = mutualinfo(d(:,i), f);
end; 
fprintf('calculate the marginal dmi costs %5.1fs.\n', cputime-t1);

[tmp, idxs] = sort(-t);
fea_base = idxs(1:K);

fea(1) = idxs(1);

KMAX = min(1000,nd); %500

idxleft = idxs(2:KMAX);

k=1;
if bdisp==1,
fprintf('k=1 cost_time=(N/A) cur_fea=%d #left_cand=%d\n', ...
      fea(k), length(idxleft));
end;

for k=2:K,
   t1=cputime;
   ncand = length(idxleft);
   curlastfea = length(fea);
   for i=1:ncand,
      t_mi(i) = mutualinfo(d(:,idxleft(i)), f); 
      mi_array(idxleft(i),curlastfea) = getmultimi(d(:,fea(curlastfea)), d(:,idxleft(i)));
      c_mi(i) = mean(mi_array(idxleft(i), :)); 
   end;

   [tmp, fea(k)] = max(t_mi(1:ncand) - c_mi(1:ncand));

   tmpidx = fea(k); fea(k) = idxleft(tmpidx); idxleft(tmpidx) = [];

   if bdisp==1,
   fprintf('k=%d cost_time=%5.4f cur_fea=%d #left_cand=%d\n', ...
      k, cputime-t1, fea(k), length(idxleft));
   end;
end;

return;

%===================================== 
function c = getmultimi(da, dt) 
for i=1:size(da,2), 
   c(i) = mutualinfo(da(:,i), dt);
end; 

互信的代码如下

function h = mutualinfo(vec1,vec2)
%=========================================================
%
%This is a prog in the MutualInfo 0.9 package written by 
% Hanchuan Peng.
%
%Disclaimer: The author of program is Hanchuan Peng
%      at <penghanchuan@yahoo.com> and <phc@cbmv.jhu.edu>.
%
%The CopyRight is reserved by the author.
%
%Last modification: April/19/2002
%
%========================================================
%
% h = mutualinfo(vec1,vec2)
% calculate the mutual information of two vectors
% By Hanchuan Peng, April/2002
%

[p12, p1, p2] = estpab(vec1,vec2);
h = estmutualinfo(p12,p1,p2);

有人知道这是什么问题吗?

2 个答案:

答案 0 :(得分:0)

如果您使用此Mutual information computation包,您可以看到,estpab函数仅针对某些平台编译(有针对Win32平台的estpab.dll,针对ELF32文件的estpab.mexglx和estpab.mexmac)对于Mac)。

因此,您必须为您的平台重新编译此程序包。 首先,您必须配置mex构建系统。调用mex -setup并选择适当的编译器。 您可以通过调用makeosmex来重新编译Mutual信息计算包。

注意:如果在编译期间遇到一些错误,例如

  

d:\ MATLAB work \ mi \ estcondentropy.cpp(65):错误C2668:&#39; log&#39; :模糊调用重载函数

您必须在muInf /= log(2);muInf /= log(2.0);

的相应文件(本例中为estcondentropy.cpp)中修改相应的行(本例中为65)

答案 1 :(得分:0)

路径中C:\Users\Desktop\是不是用户丢失了?

通常,Windows路径类似于C:\Users\Username\Desktop\

您可能添加了错误的路径,因此程序根本找不到函数estpab