My ultimate aim is to have a function which I can feed into scikit-learn's NearestNeighbor
class as a custom metric
parameter.
Existing packages
I have been researching existing libraries for a while.
The only thing I found was this KMeans package, for python 2 and based on implementing a C library. I could neither load it in with ctypes
nor convert it into an executable with gcc
.
I also found this other C code and this Matlab script but with similar results.
Implementation
I also looked into a few papers, to see if I can implement it by myself. For instance, based on this I understand that the main thing I need to do is to calculate the tangent matrix. But, I do not understand
- how do I define $s(p, \alpha)$ and especially
- how do I calculate the derivatives in python.
I would be glad for any help, comment, whatsoever.
Update
As suggested, I raised the following related issues/requests:
Update 2
@ComeOnGetMe rewrote his code so it can be used along the scikit-learn specifications (example code). Many thanks for that! Nonetheless, when I tried to use it in scikit-learn it underperformed and was very slow, so there is further work needed with that.
Since then I also found a more detailed explanation for code implementation, although based on the C code already mentioned.