Machine Learning Refined: Foundations, Algorithms, and Applications