2

У knn есть параметр weights со значением uniform по дефолту

Какой смысл от этого параметра вообще, если весы для всех соседний одни и не зависят от расстояния

1 ответ 1

1

Веса расчитываются во время обучения модели. Параметр weights позволяет управлять тем как эти веса будут расчитаны:

weights : str or callable, optional (default = ‘uniform’)

weight function used in prediction. Possible values:

‘uniform’ : uniform weights. All points in each neighborhood are weighted equally.

‘distance’ : weight points by the inverse of their distance. in this case, closer neighbors of a query point will have a greater influence than neighbors which are further away.

[callable] : a user-defined function which accepts an array of distances, and returns an array of the same shape containing the weights.

2
  • Я спрашиваю о том, в каких случаях будет полезно использовать uniform.Просто мне кажется, что это значения параметра weights является бесполезным.В этом вопрос
    – potemin
    25 окт 2018 в 8:04
  • @potemin, вы понимаете что написано в описании параметра weights? Там как раз описан ответ на ваш вопрос ;) 25 окт 2018 в 8:07

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.