Training and splitting a custom dataset
6 次查看(过去 30 天)
显示 更早的评论
Hello there, everyone. I recently worked in Matlab using deep learning and made the dataset in the program, but I don't know how to split and train this data
DatasetMatlab.mat .... this dataset , and consist of three parts
parts :-
1- LabelData
2- DataSource
3- LabelDefinitions
0 个评论
回答(1 个)
Sulaymon Eshkabilov
2023-1-29
In this case, there are a few ways - cvpartition() and datasample() to split/partition the data into training and test data sets, e.g.:
X = INPUT_Data;
Y = OUTPUT_Data;
rng("default"); % For reproducibility
n = length(Y);
%% cvpartition()
C = cvpartition(n, "HoldOut", 0.25); % Randomly selected 25% of data are used for testing and 75% for training
INDEXtrain = training(C,1);
INDEXtest = ~ INDEXtrain;
X_test = X(INDEXtest,:);
Y_test = Y(INDEXtest,:);
X_train = X(INDEXtrain,:);
Y_train = Y(INDEXtrain,:);
...
%% datasample()
NSample = 200; % 200 data sets are taken randomly for training
[Xtrain, Xtrain_Idx] = datasample(XYData, NSample);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!