Naive implementation of Kernel in Python