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?
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.