More bend costs more columns, so you want the smallest degree that already fits the data well.
Write smallest_good_degree(xs, ys, max_degree, target).
max_degree, in order.make_pipeline(PolynomialFeatures(degree), LinearRegression()) on all the points, with xs as the only feature.score (this gives R²).target, as an int.max_degree reaches target, return 0.Compare the unrounded R² with target.