Optimal Downsampling for Imbalanced Classification with Generalized Linear Models