Dimensionality reduction with validation