divide data set in matlab code
显示 更早的评论
How can divide dataset into 80% training set and 20% test set in matlab code??
回答(2 个)
Walter Roberson
2015-5-17
nrows = size(YourData,1);
r80 = round(0.80 * nrows);
trainingset = YourData(1:r80,:,:);
testset = YourData(r80+1:end,:,:);
3 个评论
Walter Roberson
2015-5-17
nrows = size(YourData,1);
r80 = round(0.80 * nrows);
rand80 = randperm(nrows,r80);
trainingset = YourData(rand80,:);
testset = YourData;
testset(rand80,:) = [];
Suzanne Hussein
2015-5-17
Walter Roberson
2015-5-17
You are using an old version of MATLAB. The equivalent code is
rand80 = randperm(nrows);
rand80 = rand80(1:r80);
Image Analyst
2015-5-17
0 个投票
randperm() is probably the function you're looking for. We can help more if you say what your dataset is.
dataset is a deprecated variable type - the Mathworks recommends that you use a table instead.
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!