Flows used to process complex soft materials almost always engender complex deformations that cannot be captured in a rheometer but may profoundly influence the final microstructure and performance of the material. Furthermore, accurate first-principles models to relate flow, microstructure, and stress are unavailable for most complex fluids, especially when undergoing complex deformations. We describe a framework that uses machine learning and data assimilation to circumvent these limitations, exploiting new experimental observations from scanning SAXS measurements in a fluidic four-roll mill. The framework automatically satisfies frame indifference and enables data-driven determination of microstructural evolution equations for complex fluids in very general flows. The approach is illustrated with simulated and experimental data with rigid and flexible polymer solutions, and the tradeoff between model fidelity and physical interpretability is studied. Finally, a methodology that integrates physical knowledge such as approximate first-principles governing equations into the data-driven framework is presented.