Optimizing the Wisdom of the Crowd: Inference, Learning, and Teaching