markdregan / K-Nearest-Neighbors-with-Dynamic-Time-Warping

Python implementation of KNN and DTW classification algorithm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Very slow execution for middle to large datasets

omarcr opened this issue · comments

Hi, is there any change in the code that you might recommend to speed up the execution of the algorithm?

DTW in general is O(n^2), so that's expected. You could look into this https://en.wikipedia.org/wiki/Dynamic_time_warping#Fast_computation

Sorry for delay - missed this. As @Nixonite mentioned, DTW is O(N^2) and it is used within a non-optimized naive KNN algorithm which is O(dN). Combining these, you get a model that doesn't scale well.