jundongl / scikit-feature

open-source feature selection repository in python
GNU General Public License v2.0
1.51k stars 447 forks source link

Maybe a mistake in reliefF.py #73

Open agnes-yang opened 2 years ago

agnes-yang commented 2 years ago

In https://github.com/jundongl/scikit-feature/blob/master/skfeature/function/similarity_based/reliefF.py

In the Algorithm Relief-F

image ( This figure is from https://link.springer.com/article/10.1023/A:1025667309714

The equation P(C)/(1-P(Class(Ri))) is in the in the numerator

The variable corresponding to this equation in the code is p_dict as below

        p_dict = dict()
        p_label_idx = float(len(y[y == y[idx]]))/float(n_samples)

        for label in c:
            p_label_c = float(len(y[y == label]))/float(n_samples)
            p_dict[label] = p_label_c/(1-p_label_idx)
            near_miss[label] = []

So in the code of calculate weight, p_dict should be in the numerator and not the denominator.

The code of

            score += near_miss_term[label]/(k*p_dict[label])

should be

            score += (near_miss_term[label] * p_dict[label]) / k
daiguaygc commented 9 months ago

I think you are right