Fitting method
Definition of fitting method
The curve obtained may not pass through all sample points, as long as the error is small enough
Determine the fitted curve
Least squares method
- One-time fitting: y = k ∗ x + by = k*x+band=k∗x+b
n is the number of samples n is the number of samplesn is a sample of this in a number of
Evaluate the fit
The function used is best to be simple. If a complex fitting function is selected, overfitting in machine learning may occur.
So we need R 2 R^2R2 Comprehensive evaluation of the complexity of the fitting function
1. The fitting function is parameter linear-goodness of fit R 2 R^2R2
-
yi represents the i-th sample point y_i represents the i-th sample point andiGeneration Table of the i th sample of the present point
-
y ˉ represents the average value of the sample \bar{y} represents the average value of the sample andˉGeneration table like this level average value
-
y ^ represents the fitted value \hat{y} represents the fitted value and^Generation Table intended engagement of values
-
S S T = S S E + S S R SST = SSE + SSR SST=S S E+SSR
-
The larger R 2 is, the better (when the complexity of the fitting function is not high), it can only be used to judge the linear fitting function, and the larger R^2 is the better (when the complexity of the fitting function is not high), it can only be used for the linear fitting function judge R2 morelargethewell(Quasifitfunctionseveralcomplexheterodegreeis nothightime),onlycapable ofusingin-lineofthe proposedclosingfunctionnumberReviewdetermination
-
The linearity discussed here is linear to the parameter rather than to the variable.
For example: y = a + b ∗ x 2 is a function that is linear to parameter a and b is a function y=a+b*x^2 is to parameter a, b is a linear functionand=a+b∗x2 ispair ofreferencenumbersA,b is the line of the function number
2. The fitting function is non-parametric linear-the sum of squared errors SSE
The smaller the SSE, the better
matlab fitting toolbox (Curve Fitting Tool)
1. The red box is a custom fitting function
2. Polynomial fitting function
Degree Choose the order by yourself
Center and scale Decentralization eliminates the influence of dimension
3.Fit Options
The Fit Options options in the above two figures:
When the fitting function is complex, the optimization algorithm will be used, and the result is an approximate solution, which means that the effect of the solution is related to the initial value (StartPoint), so when the effect of the solution is not good , You can modify Fit Options->StartPoint
Draw directly on the known function
y = @(x)exp(x);
fplot(y,[-1,10])
- fplot draws an anonymous function
- y defines an anonymous function
- The second parameter of fplot is the range of x drawn