Check this out
https://github.com/shogun-toolbox/shogun/blob/master/src/shogun/lib/tapkee/routines/locally_linear.hpp#L85