I am trying to make custom weights for Sklearn KNN classifier, similar as here. In documentation is just briefly mentioned that you can set custom weights as a user-defined function which accepts an array of distances, and returns an array of the same shape containing the weights. here.
How can I make that function for squared distance or linear weights? I went trough countless pages of SO, but without any luck. Is there a walkthrough or correct example?