Search code examples
logistic-regressionknn

Why is the accuracy of the logistic regression classifier different from k-nearest neighbors?


I understand how to compute accuracy for each but I don't understand why they are different.


Solution

  • First of all, the KNN is a deterministic algorithm, it means if you keep the value of K and run the algorithm n times, the results will be the same.

    On the other hand, the logistic regression is a stochastic algorithm. It means the algorithm use some random values to achieve it's goal. If you run the algorithm many times you'll see the results varying. It's normal, although you wanna reduce this variation.

    Second, they're different algorithms. It's normal get different accuracies when you apply different algorithms for the same problem. There's no silver bullet in this kind of problem. You need to find the best algorithm that fits in your problem. Sometimes, a algorithm that achieve a very good accuracy in a given problem A is not good for problem B.