Threshold Learning for Optimal Decision Making