Lecture Note
University
Stanford UniversityCourse
CS229 | Machine LearningPages
3
Academic year
2023
anon
Views
39
Knowing how W, B, Cost Function, and Straight LineFits Relate to One Another A continuous dependent variable can be predicted using the widely usedstatistical technique of linear regression with one or more independent variables.Two parameters, w and b, are used in linear regression to establish the line ofbest fit. We shall examine the connection between w, b, the cost function, andstraight line fits in this article. What do W and B mean? The parameters of the best-fit line in linear regression are W and B. The changein the dependent variable with respect to an independent variable is shown by W,commonly known as the slope. B, on the other hand, stands for the location ofthe line's y-axis intersection. The Line of Best Fit: How Do W and B Affect It? The values of W and B determine the optimal line of fit. The slope andy-intercept of the line will change when the values of W and B change,respectively. As a result, the line of greatest fit will likewise alter, possiblyaffecting how well the data fits. Price Function Finding the line of best fit that minimizes the discrepancy between the predictedvalues and the actual values of the dependent variable is the objective of linearregression. A cost function, which assesses the error between the forecasts andthe actual data, is used to determine this difference. The best values of W and Bare chosen by calculating the cost function using a mathematical calculation,such as the sum of squared errors. Relationship between W, B, Cost Function, and Straight Line FitsVisualized Let's examine some W and B visuals to comprehend how they relate to the costfunction. Think about a specific location on a graph to help with this. W isapproximately equal to -0.15 at this point, while B is approximately 800. Thispoint relates to a single pair of W and B values that employ a specific cost.
You might observe that this line does not provide a good fit to the data if youlook at the training set's data points. Many of the predictions for the value of thedependent variable for this line and these W and B values are extremely far fromthe actual target value that is in the training data. The cost of this line isconsiderable since this line's choice of W and B is just not a suitable fit for thetraining set. Let's examine a different scenario with a different W and B selection. Consideranother line that fits the data somewhat less poorly but is still not a fantastic fit.This line is produced by the cost for this pair of W and B. W has a value of 0 andB has a value of around 360. This set of variables results in a flat line.
A second choice of W and B results in a line that is not a great fit to the data andis further from the minimum than the previous example. This example is yetanother example with a different choice of W and B. The center of the smallestellipse contains the minimum. Finally, take into account a line that appears to fit the training set rather well.Although it is not nearly the least, the cost is quite close to the center of thesmaller ellipse. You obtain a line that is a better fit to the training set for thesevalues of W and B.
Deciphering W, B, and Cost Function in Linear Regression
Please or to post comments