Stratified K-fold validation using crossval funtion
7 ビュー (過去 30 日間)
古いコメントを表示
I am trying to customize the "Weighted kNN"-based classification code generated after a 10-fold cross validation on my data using the Classification Learner App (Using the Generate Function option in the app).
Query 1:
partitionedModel = crossval(trainedClassifier.ClassificationKNN, 'KFold',10);
After generating the code, I found that the above code is responsible for partitioning the data. I have an imbalanced dataset and I believe that "Stratified" k-fold cross validation ensures equal amount of data is considered from each class.
Query: Does the above code automatically perform Stratified k-fold cross validation? If not, how do I include it in the code?
0 件のコメント
回答 (1 件)
Rahul
2025 年 3 月 12 日
You correctly identified 'crossval' function to be responsible for partitioning the data. Considering you are applying 'KFold' cross validation to your data, the 'crossval' function would stratify the data by default i.e. ensure equal amount of data is considered from each class.
For other categories of cross-validation tasks based on classification or if a particular class or list of class labels need to be specified to be specifically stratified, the 'Stratify' property of the 'crossval' function needs to be adjusted apprpriately.
The following MATLAB Answer can be referred:
The following MathWorks documentations can be referred to know more:
'Stratify' (crossval): https://www.mathworks.com/help/stats/crossval.html#mw_35debc35-cab8-4ad9-a97d-b039ac03a22b
Thanks.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Classification Learner App についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!