I'm using the mlr package for knn (both for classification and regression problems), e.g.:
knnTask <- makeClassifTask(data = df_train, target = "CLASS")
knn <- makeLearner("classif.knn", par.vals = list("k" = 4))
knnModel <- train(knn, knnTask )
knnPred <- predict(knnModel, newdata = df_train)
I have two question:
1) Is there a way to view all individual neighbors when predicting?
2) Furthermore, is there a way to change the voting rule, e.g. using the median instead of the mean when applying knn to a regression problem?
If possible, I would like to stick to the mlr environment.
Thanks!
Best,