algorithm - 使用 Bhattacharyya 距离进行特征选择

标签 algorithm machine-learning data-mining feature-selection

我有一组使用图像处理提取的 240 个特征。 目标是在训练后将测试用例分为 7 个不同的类别。对于每个类,大约有 60 个观察值(即,每个类有大约 60 个特征向量,每个向量有 240 个分量)。

许多研究论文和书籍都使用顺序向前搜索或顺序向后搜索从特征向量中选择最佳特征。 下图给出了顺序前向搜索算法。 Here is a snapshot of the SFS algorithm

任何此类算法都使用某种标准来区分特征。一种常用的方法是使用 Bhattacharyya 距离作为标准。 Bhattacharyya 距离是分布之间的散度类型度量。在一些研究和研究中,我发现给定 A 类的矩阵 M1,该矩阵由此类的所有 60 个特征向量组成,因此它具有 n=60 行和 m=240 列(因为总共有 240 个特征)和类 B 的相似矩阵 M2 我可以找出它们之间的 Bhattacharyya 距离并找到它们的相互依赖性。

我的问题是如何将两者结合起来。如何将 Bhattacharyya 距离作为选择上述算法中最佳特征的标准。

最佳答案

在 Arthur B. 的帮助下,我终于理解了这个概念。 这是我的实现。尽管我使用了 Plus l Take away r 算法(顺序向前向后搜索),但我会发布它,因为一旦删除向后搜索,它基本上是相同的。下面的实现是在 matlab 中,但非常容易理解:

S=zeros(Size,1); %Initial the binary array feature list with all zeros implying no feature selected
k=0;
while k<n  %Begin SFS. n is the number of features that need to be extracted
t=k+l;     %l is the number of features to be added in each iteration
while k<t
    R=zeros(Size,1);  %Size is the total number of features
    for i=1:Size
        if S(i)==0    %If the feature has not been selected. S is a binary array which puts a one against each feature that is selected
            S_copy=S;
            S_copy(i)=1;
            R=OperateBhattacharrya(Matrices,S_copy,i,e,R);  %The result of each iteration is stored in R
        end
    end
    k=k+1;   %increment k
    [~,N]=max(R);  %take the index of the maximum element in R as the best feature to be selected
    S(N)=1;        % put the index of selected feature as 1
end
t=k-r;    %r is the number of features to be removed after selecting l features. l>r
while k>t  %start Sequential Backward Search 
    R=zeros(Size,1);
    for i=1:Size
        if S(i)==1
            S_copy=S;
            S_copy(i)=0;
            R=OperateBhattacharrya(Matrices,S_copy,i,1,R);
        end
    end
    k=k-1;
    [~,N]=max(R);
    S(N)=0;
end
fprintf('Iteration :%d--%d\n',k,t);
end

希望对遇到类似问题的人有所帮助。

关于algorithm - 使用 Bhattacharyya 距离进行特征选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19607681/

相关文章:

java - 在某些情况下,一种逻辑的最少步骤失败

machine-learning - 软注意力 vs. 硬注意力

javascript - 如何训练 LSTM 在 tensorflow.js 中对垃圾邮件进行分类?

python - 在 Tensorflow2 中将图卡住为 pb

sql - 顺序模式 - 数据挖掘

algorithm - 如何编写函数以某种概率返回值?

c# - 计算反射弧

algorithm - 何时停止凝聚层次聚类 - 停止标准

algorithm - 在哪里可以找到有关交易算法的免费教程

java - 如何判断一个字符串是随机生成的还是似是而非的英文单词?