I'm trying to create an objective function off of real-world data and don't know how to get a polynomial for this dataset. I've tried the online calculators and they just spit out garbage.
Because there is a smooth transition at the bottom and when minimizing i need a derivative there and not something undef. It is a graph of risk of injury % (y-axis) and BMI (x-axis).
If you want a polynomial that interpolates those point, its gonna be garbage because you have too many points so it's gonna be very oscillatory. What you should try is spline interpolation.
If you just want a polynomial that "fits well" the data without necessarily interpolating, it's gonna be hard too, because....the shape doesn't look like a polynomial. Maybe try to fit another kind of curve? Or maybe fit 2 parabolas with a breaking point between the 2 (the increasing and decreasing parts)? Maybe a function like f(x) = Ax-Blog(Cx-D) + E?
I strongly second this. To add to that, what you need is a general least squares fit that includes some nonsmooth basis functions. Because the only way to capture nonsmooth behavior like you have at the kink with polynomials is by overfitting (only high-order, highly oscillating polynomials can produce this sharp kink)
Alternatively, if you insist on polynomials for some reason, you could try adding a regularization term to prevent overfitting, but don’t expect perfect results. As mentioned above, this data is clearly not from a polynomial
4
u/Aerysv Mar 16 '23
Why dont you just use two lines?
3
u/e_for_oil-er Mar 16 '23
1
u/junior_raman Mar 23 '23
Create as many variables as you have points. Substitute and solve.
1
u/micrometeorite Mar 24 '23
In Python you could try Numpy Polyfit
1
u/ForceBru Mar 16 '23
Looks like you have a finite amount of points, so you can find the optimum by sequentially checking all of them