scikit-learn-contrib / DESlib

A Python library for dynamic classifier and ensemble selection
BSD 3-Clause "New" or "Revised" License
477 stars 106 forks source link

"n_neighbors" is not a multiple of "n_classes" in KNNE #247

Closed jayahm closed 3 years ago

jayahm commented 3 years ago

Hi

I got this warning when using KNNE: https://github.com/scikit-learn-contrib/DESlib/blob/6ae0f5a8f837f1843ccf0a48ae89e911108aa3d2/deslib/util/knne.py#L243

            warnings.warn('"n_neighbors" is not a multiple of "n_classes". Got'
                          '{} and {}.One or more classes will have one less'
                          ' instance.'.format(n_neighbors,
                                              self.n_classes_))

I understood that n_neighborsrequires a multiply of a number of classes. But, for example, if I set n_neighbors =7 for binary classification of two classes, does it mean the final n_neighbors will be 6?

How about n_neighbors = 11 but with 3 classes? The final n_neighbors is 3 for each class?

Menelau commented 3 years ago

@jayahm Hello,

the n_neighbors is still 7, however, the number of neighbors will be 4 belonging to one class and 3 belonging to the other (one class having more neighbors than the other).

jayahm commented 3 years ago

I see. Thanks.