• Numpy piece-wise function evaluation
numpy.piecewise(x, condlist, funclist, *args, **kw)
  • Evaluating a Gaussian Kernel ,
import scipy as sp
from scipy.spatial.distance import pdist, squareform
# X --> N x d array (each row is a data point with d entries and N data points are available)
distances = squareform(pdist(X, 'euclidean'))
K = sp.exp(-distances**2 / l**2)
  • Treat all numpy warnings as errors, i.e. raise an exception and stop execution (useful to debug)
numpy.seterr(all='raise')