Accelerating machine learning algorithms with adaptive sampling