YOLOv5/v7 implements K-fold cross-validation tutorial: Solve the problem of sparse data set samples and category imbalance

I wrote an article before YOLOv8to realize the process of kfolding cross-validation . Many students want to try it in v5/v7, so the tutorial is here.


K-fold cross-validation

concept

KFolded cross-validation (K-fold cross-validation)is a technique commonly used to evaluate the performance of machine learning models.

It can make more full use of the limited data set, reduce the bias caused by improper data division, and improve the generalization ability of the model.

KThe basic idea of ​​folded cross-validation is to divide the original data into Ksubsets, called "folds" (Fold), of which K-1subsets are used to train the model and the remaining 1subsets are used to test the model.

This process is repeated Kseveral times, each time selecting a different 1subset as the test set, and finally obtaining Kthe evaluation results of the model performance, which are usually averaged to obtain the final evaluation index.

Please add a picture description


step

  1. Dataset partitioning: The original dataset is randomly divided into Ksubsets, ensuring that each subset has a similar number of samples. Typically, Kthe value of is 5or 10, but other values ​​can be chosen in some cases.

  2. train and test

Guess you like

Origin blog.csdn.net/weixin_43694096/article/details/132397729