A plant's height over a season rises, levels off, then drops as it wilts. You have some measurements split into training points and held-back test points.
Write scores_by_degree(x_train, y_train, x_test, y_test, degrees).
For each degree in degrees, in order:
make_pipeline(PolynomialFeatures(degree), LinearRegression()) on the training points, with x as the only feature.score gives R²).Return a list with one [degree, train_score, test_score] per degree. Round both scores to 3 decimal places.