Sampling Techniques for Supervised or Unsupervised Tasks