Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How to view all k neighbors when performing knn with the mir package?

$
0
0

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,


Viewing all articles
Browse latest Browse all 201839

Trending Articles