  Kernel methods augmented with random features give scalable algorithms for
learning from big data. But it has been computationally hard to sample random
features according to a probability distribution that is optimized for the
data, so as to minimize the required number of features for achieving the
learning to a desired accuracy. Here, we develop a quantum algorithm for
sampling from this optimized distribution over features, in runtime $O(D)$ that
is linear in the dimension $D$ of the input data. Our algorithm achieves an
exponential speedup in $D$ compared to any known classical algorithm for this
sampling task. In contrast to existing quantum machine learning algorithms, our
algorithm circumvents sparsity and low-rank assumptions and thus has wide
applicability. We also show that the sampled features can be combined with
regression by stochastic gradient descent to achieve the learning without
canceling out our exponential speedup. Our algorithm based on sampling
optimized random features leads to an accelerated framework for machine
learning that takes advantage of quantum computers.
