Self-learning quantum Monte Carlo: Application to the classical Holstein spin-fermion model