Here we will show an example of cost function for linear regression for house price prediction. Please note that instead of Linear Regression we could also use another type of function (For example: Neural Network) to make the prediction.

Dataset

size num_rooms distance_from_city_center price
77.450712 1 15.246737 261664.241553
67.926035 5 16.625528 261201.133267
79.715328 1 13.672505 258851.548821
92.845448 3 5.227514 347030.131111
66.487699 2 6.244103 237025.276669

Prediction function

f(input)=output

f(size, num_rooms, distance_from_city_center) =

$$ size * \theta_1 + num\_rooms * \theta_2 + distance\_from\_city\_center * \theta_3 = predicted\_price $$

Let’s refer to size, num_rooms, distance_from_city_center and price as $x_1,x_2,x_3,y$ for better reading experience.