How to Split test and training set
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
UTHOWAIPRU CHOWDHURY BAICHING
am 22 Jun. 2022
Kommentiert: UTHOWAIPRU CHOWDHURY BAICHING
am 26 Jun. 2022
I am stuck on how split train and test data correctly.
XTrain = readtable("urbanGB.csv");
YTrain = readtable("urbanGB.labels.csv");
0 Kommentare
Akzeptierte Antwort
Garmit Pant
am 23 Jun. 2022
Hello Uthowaipru
It is my understanding that you have data in the form of CSV files that you wish to load and split into train and test subsets.
You can use the 'cvpartition' function of the Statistics and Machine Learning Toolbox to do the same.
You'll can use the following code snippet to divide your data into training and test subsets.
XTrain = readtable("urbanGB.csv");
YTrain = readtable("urbanGB.labels.csv");
XTrain.Y = table2cell(YTrain); %assuming YTrain to be a single column
rng('default') % For reproducibility
n = length(XTrain.Y);
hpartition = cvpartition(n,'Holdout',0.3); % Nonstratified partition
idxTrain = training(hpartition);
tblTrain = tbl(idxTrain,:);
idxTest = test(hpartition);
tblTest = tbl(idxNew,:);
You can refer to the documentation of cvpartition for more details: cvpartition
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Model Building and Assessment finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!