How do I calulate the R2 score of a fitted polynomial regression curve whereby one x point has multiple true y-values?

The sklearn r2_score(ytrue, ypred) method fails with this error because i have 13 ypred points, but 48 ytrue points

ValueError: Found input variables with inconsistent numbers of samples: [48, 13]

Is my concept of fitting a polynomial regression in such a manner wrong? The reason why there are multiple ytrue points for the same x-point is because they are each contributed by a different Id (eg. person)

Should i not lump the data points of each person to the plotting space? And rather fit a curve for each person instead, and then aggregate the coefficients (ie. sum all the polynomial coeffs and divide by the number of people).


For each prediction in ypred you need to enter the true value in ytrue. So you need to repeat the values in ytrue so that they are properly paired with the values in ypred.

| cite | improve this answer | |

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.