{"id":641,"date":"2018-05-29T03:19:43","date_gmt":"2018-05-29T03:19:43","guid":{"rendered":"http:\/\/muthu.co\/?p=641"},"modified":"2021-05-24T03:47:18","modified_gmt":"2021-05-24T03:47:18","slug":"evaluating-the-fitness-of-a-modal-using-a-cost-function","status":"publish","type":"post","link":"http:\/\/write.muthu.co\/evaluating-the-fitness-of-a-modal-using-a-cost-function\/","title":{"rendered":"Evaluating the fitness of a modal with a cost function"},"content":{"rendered":"\n
Previously<\/a> we derived a simple linear regression modal for our Pizza price dataset. We built a modal that predicted a price of $13.68 <\/strong>for a 12 inch pizza. <\/strong>When the same modal is used to predict the price of an 8 inch pizza, we get $9.78 which is around $0.78 more than the known price of $9. This difference between the price predicted by the modal and the observed price in the training set is called the residual or training error. Below table shows the residuals<\/strong> for our training set.<\/p>\n\n\n\n A much better pizza price predictor would be a modal where the sum of training error is as least as possible. We can produce the best pizza-price predictor by minimizing the sum of the residuals. That is, our model fits if the values it predicts for the response variable are close to the observed values for all of the training examples. This measure of model’s fitness is called the residual sum of squares cost function. <\/strong>The residual sum is calculated using the below formula where yi<\/sub><\/em> is the observed value and f(xi<\/sub>)<\/em> is the predicted value.<\/p>\n\n\n\n<\/a><\/figure><\/div>\n\n\n\n