Implements sample_weight for sklearn.neighbors.KNeighborsClassifier#33588
Implements sample_weight for sklearn.neighbors.KNeighborsClassifier#33588JacobHass8 wants to merge 18 commits intoscikit-learn:mainfrom
sample_weight for sklearn.neighbors.KNeighborsClassifier#33588Conversation
|
@lorentzenchr would you mind reviewing this PR? If this works, I can use it as a template for the other estimators in One issue I had was with the function One way I could see of reconciling this is by removing any duplicate data points before running the predictions and increasing the I'm also unsure how |
Reference Issues/PRs
Fixes #33457.
What does this implement/fix? Explain your changes.
Implements
sample_weightsargument for thefitmethod of thesklearn.neighbors.KNeighborsClassifierestimator. If theweightsparameter is passed toKNeighborsClassifier, then we simply multiple the distance andsample_weightstogether.Comments
I haven't added many tests for this argument. The only tests check the following:
sample_weightsarray doesn't effect predicted valuessample_weightsdoes not have the same size asYinfit(X, y, sample_weights=..), then an error is thrownsample_weights<= 0, then an error is thrownI think there should be at least one test with non-uniform weights. Would translating tests from another Estimator work?
AI usage disclosure
N/A