This project implements the n degree Polynomial Regression in python. The class called 'Polynomial_Regression' receives 3 parameters x,y and polynomial function degree that will be generated to fit in the data. To show the code works, 2 datasets were obtained in chapter 20 of the book 'Numerical Methods for Engineers'.
f = [7,9,15,25,40,75,100,150]
k = [0.29,0.37,0.48,0.65,0.8,0.97,0.99,1.07]
model = Polynomial_Regression(k,f,2)
model.building_the_linear_system()
model.generate_graph(title='Regressão quadratica nos dados',save_graph=True)
In the second, it was carried out 1, 2, 3 and 4-degree regression. We can note that a good fit was achieved using 3 degrees. However, the 4-degree polynomial regression creates a huge concavity between 4 and 5 dots by the absence of dots in that area and high degree.
y = [0,2.3,4.9,9.1,13.7,18.3,22.9,27.2]
x = [22.8,22.8,22.8,20.6,13.9,11.7,11.1,11.1]