How can we know which degree polynomial is the best fir for a data set composed of one predictor and one variable? And how can we evaluate them?

I have developed the linear regression and then went up to the third polynomial degree, but I just need to make how to assess the goodness of fit?

  • 2
    $\begingroup$ You assess goodness of fit with cross validation. You pick a degree most generally by not picking a degree, instead you should use cubic splines, or if you must use polynomials, pick a highest degree you are willing to tolerate, and then use regularization to pick the correct complexity. $\endgroup$ – Matthew Drury Feb 13 '17 at 0:55

This question can be generalized for selecting any machine learning algorithm hyper-parameters. For example, number of clusters in K-means, number of Hidden unit in neural networks, etc.

At very high level, there are two ways (not mutually exclusive, in fact combining two ways would be ideal.): Data driven and knowledge driven.

  • Data driven means using data to figure out which one is the best. We usually have training set and testing set. There are some other variations, such as adding one additional validation data set, run repeated cross validation etc. But the overall idea is and pick the best one in testing set, and we can make sure testing set is very close to production data.

  • Knowledge driven means using "domain knowledge" to make the decision on parameter tuning. For example, we are fitting some data from some trajectory data and we know our data from physics would generally follow a parabola trend, not a 5th order polynomial curve. Then we would like pick the 2nd order polynomial to fit. In addition, if we know our data is periodic, we may choose Fourier expansion on the data instead of polynomials. See this post What's wrong to fit periodic data with polynomials?

In sum, if we have a lot of data, and can make sure we have a fair representation to production data in testing set. Then data driven would be good. On the other hand, if we have lots of domain knowledge about the relationship between input and output, then knowledge driven is good. The ideal case would be combining two: know the relationship in data and testing it carefully using a good testing set.

| cite | improve this answer | |

In a polynomial regression process(gradient descent) try to find the global minima to optimize the cost function. We choose the degree of polynomial for which the variance as computed by


is a minimum or when there is no significant decrease in its value as the degree of polynomial is increased. In the above formula,

  • Sr(m) = sum of the square of the residuals for the mth order polynomial
  • n= number of data points
  • m=order of polynomial (so m+1 is the number of constants of the model)

Refer : https://autarkaw.org/2008/07/05/finding-the-optimum-polynomial-order-to-use-for-regression/

| cite | improve this answer | |
  • $\begingroup$ Don't know what you mean by "where the cost is minimal, so the residual must be tends to zero". $\endgroup$ – Michael R. Chernick May 7 '18 at 5:28
  • $\begingroup$ i have rephrased, hope it will work :) $\endgroup$ – Reeves May 7 '18 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.