0
$\begingroup$

I've two text files which contains my data. One text file on X axis another text file on Y axis Then using scatter function from python I did the data visualization After that, I used polyfit function from python to get the curve which will fit my data In that polyfit function we need to write degree of the polynomial we want eg. 2 or 3 Now let's consider I got 4 such a equations of degrees 2,3,4,5 respectively. Now here comes my problem. Among all those equations I got, how can I select the best equation which fits my data. I want to use cross validation here. Any high level library function can be use. My language is Python.

$\endgroup$
2
$\begingroup$

I think that you want this:

K-fold

If you want say MSE of each check out section 3.1.1 here:

cross validated metrics

| improve this answer | |
$\endgroup$
1
$\begingroup$

If instead of Numpy's polyfit function, you use one of Scikit's generalized linear models with polynomial features, you can then apply GridSearch with Cross Validation and pass in degrees as a parameter. It will find the best model based on the input features (i.e. 2,3,4,5).

| improve this answer | |
$\endgroup$

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.