This post was last edited by Zhao_kar on 2024-3-3 15:38
The Beauty of Control (Volume 2) Section 7 - Matrix Derivative Example - Linear Regression
statement:
- This section uses a simple practical example to expand the vector matrix derivative, also the previous athlete example
- There are only 15 athletes and only two variables need to be considered: height and weight.
Example introduction:
- First, we can draw a scatter plot of height + weight based on the data. Generally, the taller the height, the heavier the weight. We can use a linear function to represent
- At this time, a prediction equation is defined as the following figure, where from left to right are the estimated height, two parameters and an actual weight.
- We need to confirm y1 and y2, and define a cost function to minimize the loss. The cost function is defined as the second formula in the figure above:
- The difference between the left and right sides of the equation is the error between the actual value and the estimated value. That is to say, when the sum of squares is minimized, the prediction equation can better reflect the relationship between the data.
- This method is called the least squares method
calculation process:
- The first step is to write the four parameters in matrix form, construct the equation, and then introduce the cost function
- Then after getting a function, divide it into three parts and do the derivation. The derivation formula is shown in the upper left part of the figure below, and the result on the right side is obtained after calculation:
-
Finally, attach the simulation verification