parisimaa / ML_PolyReg

Polynomial Regression

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ML_Polynomial_Reg

This is a problem of fitting a Polynomial function for finding a one-dimentional function. d is the degree of the polynomial.
We need to find a theta that minimize the risk:
Screen Shot 2022-11-01 at 3 51 49 PM
Use Problem1.mat file as the dataset which consists of input variable X and output Y. Split the dataset randomly into training and test sets (you need to adjust some parameters for other datasets). Cross-validation has been used for finding the optimum order of the polynomial function.
Result:
Screen Shot 2022-11-01 at 3 58 25 PM
By increasing the order of polynomial function training loss will decrease significantly and our model will adjust to training set almost perfect. However, as the orders increase our model performance on test set will not be stable and at some point, not only loss function will not improve but also will start increasing again. The point in which the minimum loss results for test set is the critical point between underfitting and overfitting of the system. In this case, the order of D = 9 is our critical point.

Order d=1:

Screen Shot 2022-11-01 at 4 09 18 PM

Order d=3:

Screen Shot 2022-11-01 at 4 09 43 PM

Order d=5:

Screen Shot 2022-11-01 at 4 10 09 PM

Order d=9:

Screen Shot 2022-11-01 at 4 10 32 PM

About

Polynomial Regression


Languages

Language:MATLAB 100.0%