cost function example machine learning