0
$\begingroup$

I have a question, related to parallel work on python

How I can use Processers =1,2,3... on k nearest neighbor algorithm when K=1, 2, 3,.. to find the change in time spent, speedup, and efficiency.

What is the appropriate code for that?

$\endgroup$

1 Answer 1

0
$\begingroup$

AFAIK KNN take time only if size of the data is very huge. Meanwhile normal GridSearchCV itself works well with more K values, Refer this site - https://machinelearningknowledge.ai/knn-classifier-in-sklearn-using-gridsearchcv-with-example/.
Still you want to run in parallel please create a method in which you fit the KNN by accepting the K value as parameter in the method.
Create subprocess for each K value in the main method and call the KNN method by passing the K value.
Code will be more complex if you write like this since we need to write logic to compare the accuracy of each fit w.r.t cross validation etc.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.