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

📄 fs_neighbor.asv

📁 属性约简的matlab代码:实现了基于信息熵、模糊信息熵;这些算法可以同时处理离散变量和数值变量
💻 ASV
字号:
%% compute reduct from numerical data, categorical data and their mixtures with neighborhood rough sets.
%% two kinds of neighborhood are used: crisp and fuzzy.
%% Variable precision neighborhood lower approximations are used to compute dependency between conditions and decision.
%% dependency 
function select_feature=fs_neighbor(data,if_fuzzy,neighbor,inclusion)
%%input
%%%input:
% data is data matrix, where rows for samples and columns for attributes. 
% Numerical attributes should be normalized into [0,1] and decision attribute is put in the last column 
% f is the label of "fuzzy" or "crisp". f=0 menas crisp neighborhoods; while f=1 means triangle fuzzy neighborhoods.
% neighborhood means the radius of neighborhood, usually takes value in [0.05  0.5]
% inclusion is the threshold to compute variable precision lower approximation, usually in [0.8, 1]
%%%output
% a reduct--- the set of selected attributes.
[row column]=size(data);
%%%%%%%%%%%%%compute relation matrices with a single attribute%%%%%%%%%
if (if_fuzzy==0)
    for i=1:column
        col=i;
        r=[];
        eval(['ssr' num2str(col) '=[];']);
        for j=1:row      
            a=data(j,col);
            x=data(:,col);
       
            for m=1:length(x)
                r(j,m)=kersim_crisp(a,x(m),neighbor);
            end
        end
        eval(['ssr' num2str(col) '=r;']);
    end  

else
    for i=1:column
        col=i;
        r=[];
        eval(['ssr' num2str(col) '=[];']);
        for j=1:row      
            a=data(j,col);
            x=data(:,col);       
            for m=1:length(x)
                r(j,m)=kersim(a,x(m),neighbor);
            end
        end
        eval(['ssr' num2str(col) '=r;']);
    end      
 
 end
%%%%%%%%%%%%search reduct with a forward greedy strategy%%%%%%%%%%%%%%%%%%%%%%%

n=[];
x=0;
base=ones(row);
r=eval(['ssr' num2str(column)]);
attrinu=column-1;
for j=attrinu:-1:1
    sig=[];
    for l=1:attrinu
       r2=eval(['ssr' num2str(l)]);
       r1=min(r2,base);
       
       importance=0;
       temp=[];
       incluse=[];
       
       for i=1:row
            temp=min([r1(i,:);r(i,:)]);
            incluse=sum(temp)/sum(r1(i,:));
            if incluse>=inclusion
                importance=importance+sum(temp)/length(find(temp~=0));
            end
        end
        
       sig(l)=importance/row;
    end
    
    [x1,n1]=max(sig);
    
    x=[x;x1];
    len=length(x);
    if abs(x(len)-x(len-1))>0.001
        base1=eval(['ssr' num2str(n1)]);
        base=min(base,base1);
        n=[n;n1];
    else
        break
    end
end

select_feature=n;


⌨️ 快捷键说明

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