- Split data into train and test sets.
- K-Fold cross-validate on the training data to estimate generalization error.
- Select the model with least generalization error.
- Train it from scratch with the entire training data
- Test it on the test data.
How to select samples to leave out when building my regression model and automate it
조회 수: 2 (최근 30일)
이전 댓글 표시
I am using fitrsvm (Support Vector Regression) on my data matrix (I have attached an excel example version of it).
I have about 22 blocks with all the intensities from their samples from column 4 to the end. The response values are on column 3 and the blocks are on the first column
I use 80% of the data to train and 20% to test
I leave out all samples form a block or more each time I build/train a model until I end up with the best model
Eact time I leave out the samples I also need them to match the response value column
I have been doing this manually but it is not a trivial process
I would like a code to automate this process bearing in mind that fitrsvm does not work with non numeric values like blocks column in the training data matrix
Can you help me the code to automate the process to leave out one or more blocks each time I build a model, please?.
Thank You
댓글 수: 0
채택된 답변
Nayan
2023년 3월 8일
As described above, I would suggest you to perform k-Fold Cross Validation. K-Fold Cross Validation helps in splitting the data into K-blocks, training the Model on "K-1" folds and testing the trained model on the left out Kth fold ( to report the generalization error). You should be performing the following steps : -
These steps can help you to automate the process.
You can go through the following link to know more about cross-validation and ease of coding your model.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!