Machine learning for FEL optimization