You have one set of points and several degrees to choose from. The honest way to choose is to hold some points back and see which degree does best on them.
Write pick_degree(xs, ys, degrees, seed).
train_test_split(X, ys, test_size=0.3, random_state=seed), where X is xs as a one-column table.degrees, fit make_pipeline(PolynomialFeatures(degree), LinearRegression()) on the training part and score it on both parts.Return a dict:
"degree": the chosen degree, as an int."train": its training score, rounded to 3 decimal places."test": its test score, rounded to 3 decimal places.