I've been working on a side project and I had to gather some data to look for a pattern. I need to find the optimal function that minimizes the Y distance for all the points in the dataset, and so far I used Geogebra to generate both a Polynomial Regression (degree 4) and a Linear Regression. However, I'm not positive whether using regression is the correct/best way to do so, as I've never worked with them.
The function I ended up using is a mix of both of them (for x <= 80, polynomial regression, else, linear regression).
This is what the graph looks like
(note: only the blue points are counted, the other ones are older/not accurate)
Is there any better way to optimize this function or any other method I could use to achieve better results?

You can solve this $L_1$ regression problem via linear programming. See problem L1 in this example.