jundongl / scikit-feature

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

Bug in `lap_score.py` #57

Open mary-design-testing opened 4 years ago

mary-design-testing commented 4 years ago

Hi there!

It seems to be an error in lap_score.py. Please, take a look at the following excerpt:

    # if 'W' is not specified, use the default W
    if 'W' not in kwargs.keys():
        W = construct_W(X)
    # construct the affinity matrix W
    W = kwargs['W']

If the user does not pre-compute W, then the last line results in a KeyError. I think it's easy to fix, since there seems to be a missing else:

    if 'W' not in kwargs.keys():
        # if 'W' is not specified, use the default W
        W = construct_W(X)
    else:
        # construct the affinity matrix W
        W = kwargs['W']

Thanks. Regards.