Linear and nonlinear dimensionality reduction from fluid mechanics to machine learning