The Cost function optimises the regression coefficients and measures the performance of a linear regression model. It helps find the accuracy of the mapping function, which maps the input variable to the output variable. Moreover, it enables you to determine the optimal values for a0 and a1 that offers the best fit line for given data points. The alternate name of this mapping function is the Hypothesis function.