To find the knots automatically in piecewise polynomial regression, which concept is BEST, cubic splines or k fold cross-validation in python
Asked
Active
Viewed 751 times
1
-
1You are mixing concepts. CV is for choosing the best Knots. Cubic splines is just a kind of piecewise regression that uses polynomials of degree 3. – josepdecid Mar 05 '19 at 07:10
1 Answers
0
How many number of Knots?
You can use Cross Validation, basically consisting in trying out different numbers of knots and see which produces the best looking curve.
Where to place the Knots?
There are multiple approaches depending on the problem, You just could use CV to also chose the positions, or choose one of the following methods:
- Place them uniformly across the domain (common method in practice)
- Put more knots in places where the data varies a lot
- Place them at percentiles of interest (e.g. 25th, 50th, and 75th)

josepdecid
- 116
- 1
-
Spasibo :) ......... one small doubt, without manually seeing and selecting the best number of knots or using for loop, does CV gives the best number of knots? – kini Mar 06 '19 at 09:20
-
Just try different number of knots with the CV and choose the one which gives a smaller loss, here you have a generic introduction to [CV](https://machinelearningmastery.com/k-fold-cross-validation/) ;) – josepdecid Mar 06 '19 at 13:14
-
I could not figure out the application of K-Fold CV in finding the number of knots, can u pls explain in detail – kini Mar 12 '19 at 12:58
-
Run the same model changing the number of knots (refer to [random search](https://stats.stackexchange.com/questions/160479/practical-hyperparameter-optimization-random-vs-grid-search)) or the positions of those and take the one which gives you the best results! – josepdecid Mar 12 '19 at 15:13