Nonlinear Energy Harvesting With Tools From Machine Learning