Tracing outbreaks with machine learning