|
Hi! Im using sci-kit learn for fit and test a KNN method, and the dataset is unbalanced/desbalanced classes and i need apply weight to class but i dont know the function to use in KNN, in other methods you can use weight=balance_weights(y_train) but in KNN i think you need a function for calculate the distances but i dont know exacly how to the method use this function and how to define correctly the weights for unbalanced problem. Sorry for my english. |
|
Hi, in scikit's KNN, you can define the weights hyper-parameter of
There are several other weight methods for KNN that are explained here, http://scikit-learn.org/dev/modules/generated/sklearn.neighbors.KNeighborsClassifier.html Typically, the distances are calculated using the euclidean distance, however, you can use other distance functions by setting the ' |