Machine learning for correcting and preventing additive manufacturing errors