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.
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).