Dimensionality Reduction for Supervised and Unsupervised Learning: New Algorithms, Analysis and Application