The ever-growing popularity and rapid improving of artificial intelligence (AI) have raised rethinking on the evolution of wireless networks. Mobile edge computing (MEC) provides a natural platform for AI applications since it provides rich computation resources to train AI models, as well as low-latency access to the data generated by mobile and Internet of Things devices. In this paper, we present an infrastructure to perform machine learning tasks at an MEC server with the assistance of a reconfigurable intelligent surface (RIS). In contrast to conventional communication systems where the principal criteria are to maximize the throughput, we aim at optimizing the learning performance. Specifically, we minimize the maximum learning error of all users by jointly optimizing the beamforming vectors of the base station and the phase-shift matrix of the RIS. An alternating optimization-based framework is proposed to optimize the two terms iteratively, where closed-form expressions of the beamforming vectors are derived, and an alternating direction method of multipliers (ADMM)-based algorithm is designed together with an error level searching framework to effectively solve the nonconvex optimization problem of the phase-shift matrix. Simulation results demonstrate significant gains of deploying an RIS and validate the advantages of our proposed algorithms over various benchmarks.