Variational Weighting for Kernel Density Ratios