How to separate features and target (numeric values) in a tabular text datastore to import into Deep Network Design?

조회 수: 7(최근 30일)
paulo silva
paulo silva 2021년 12월 2일
편집: paulo silva 2021년 12월 8일
Hello everyone, I have the following problem: I imported a csv file with numerical data containing the features and the target into a tabular text datastore, however, to import into Deep Network Design this tabular text datastore needs to contain separate features and target. I have no idea how to do this, can someone give me a hand?
For example, my csv file has 500 rows 10 features and the target.
Thank you very much!


yanqi liu
yanqi liu 2021년 12월 3일
yes,sir,may be choose the data to X and Y,such as
% 500 rows 10 features and the target.
X = Data(:, 1:10); % 10 features
Y = Data(:, end); % target
may be upload some data mat to do analysis
  댓글 수: 3
paulo silva
paulo silva 2021년 12월 4일
Hi Yanqi, thanks again for your help and proactivity. But after many tests and analysis of the structure of a tabular test datastore, I found a way that solves the issue and separates the 10 features from the target:
dsTrain = tabularTextDatastore("datasetrain.csv");
dsnewTrain = transform(dsTrain, @(x) [cellfun(@transpose, mat2cell(x{:,1:10},ones(1,500)),'UniformOutput',false), mat2cell(x{:,11},ones(1,500))])
dsValid = tabularTextDatastore("datasevalid.csv");
dsnewValid = transform(dsValid, @(x) [cellfun(@transpose, mat2cell(x{:,1:10},ones(1,250)),'UniformOutput',false), mat2cell(x{:,11},ones(1,250))])
dsTest = tabularTextDatastore("datasettest.csv");
dsnewTest = transform(dsTest, @(x) [cellfun(@transpose, mat2cell(x{:,1:10},ones(1,250)),'UniformOutput',false), mat2cell(x{:,11},ones(1,250))])
Again, thank you very much for your help and for those who have the same problem as me, this solution solves it simply. :)

댓글을 달려면 로그인하십시오.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by