Non-Parametric Learning of Gaifman Models