Predicting and Optimizing Li-ion Battery Lifetimes with Machine Learning