Supervised learning via clustering