Learn then Test: Calibrating Predictive Algorithms to Achieve Risk Control