Exercise solution to machine learning on coursera (https://class.coursera.org/ml-005)