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

📄 fs_con_n.m

📁 属性约简的matlab代码:实现了基于信息熵、模糊信息熵;这些算法可以同时处理离散变量和数值变量
💻 M
字号:
%% 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 is employed as the heuristic rule.
function [select_feature,attr_sig]=fs_con_N(data,neighbor)
%%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 
% neighborhood means the radius of neighborhood, usually takes value in [0.05  0.5]
%%%output
% a reduct--- the set of selected attributes.
[row column]=size(data);
classnum=max(data(:,column));
%%%%%%%%%%%%%compute relation matrices with a single attribute%%%%%%%%%

    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  


 

%%%%%%%%%%%%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=[];       
       
       for i=1:row
            temp=r1(i,:);
            
            neighbor_loc=find(temp==1);
            label_value_N=data(neighbor_loc,column);
            
            for class_i=1:classnum                
                class_i_num_N(class_i)=length(find(label_value_N==class_i));                
            end
            
            [value,real_class]=max(class_i_num_N);
            if (data(i,column)==real_class)
                importance=importance+1;
            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

attr_sig=x(2:(length(x)-1));

select_feature=n;


⌨️ 快捷键说明

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