Weighted Distance In Sklearn Knn
I'm making a genetic algorithm to find weights in order to apply them to the euclidean distance in the sklearn KNN, trying to improve the classification rate and removing some char
Solution 1:
There is indeed another way, and it's inbuilt into scikit-learn (so should be quicker). You can use the wminkowski
metric with weights. Below is an example with random weights for the features in your training set.
knn = KNeighborsClassifier(metric='wminkowski', p=2,
metric_params={'w': np.random.random(X_train.shape[1])})
Post a Comment for "Weighted Distance In Sklearn Knn"