Hello all,
I am taking the “Supervised Machine Learning: Regression and Classification” course by Dr. Andrew Ng from Coursera. Can you anyone guide me where is the function “cost_function” defined. I cannot find it in any of the notebooks. It is first used in "C1_W1_Lab04_Gradient_Descent_Soln
" I would really appreciate it.
Thank you.
That variable cost_function is a “formal parameter” to the function gradient_descent, so that means it is a local variable within the body of that function. You can pass a reference to a function as an argument to another python function.
Then when they call gradient_descent, they pass the function compute_cost as that parameter:
That was defined earlier in this notebook:
So when gradient_descent is executed by that test cell, the cost function actually being called is compute_cost and cost_function is simply the variable that we use to reference the actual function.