I have trained two models using sklearn library in python.. My dataset was about 750 features, 250 features per class (three classes), I trained only one feature dimension (1-D array). This are the results:
- SVM
Between training process and testing process (0.20%) I got: 0.029801 sg
- KNN
Between training process and testing process (0.20%) - 0.0074096 sg
As we can see K-NN got a shorter execution time ≈ 7 milliseconds and SVM 29.801 milliseconds.
I'm interested in knowing what of this two models are more complex computationally. According to [1] the complexity of SVM (LibSVM) is O(n^3) Sklearn is using libsvm like backend or like solver for svm problems (linear and non-linear)
According to [2] the complexity of K-NN is O(nd)
"Since the large O notation only gives a higher asymptotic dimension, and not an asymptotically adjusted upper bound, we can make statements that at first glance seem incorrect, but that are technically correct. For example, it is absolutely correct to say that the binary search is executed at a time O (n), That's because the execution time grows no faster than a constant multiplied by n. In fact, it grows slower." [3]
What is more complex? O(n^3) or O(nd) and Why?
Since my point of view KNN is more less complex in time execution that SVM model. thanks so much.
[1] https://core.ac.uk/download/pdf/48595285.pdf [2] k-NN computational complexity [3] https://es.khanacademy.org/computing/computer-science/algorithms/asymptotic-notation/a/big-o-notation