Text this: Coarse-graining network flow through statistical physics and machine learning