Data-driven optimization of therapy for heart failure