Cross-validation plays a crucial role in determining the hyperparameters while implementing any ML algorithm. This video explains it quite well.

https://www.youtube.com/watch?v=fSytzGwwBVw