I want to set a .CSV file as a datastore, and then set the fifth and the fourth columns as predictors, and the third column as the target.
2 次查看(过去 30 天)
显示 更早的评论
I want to designate a CSV file as a data store. Then I want to transform the 5th and the 4th columns as predictors to my neural network. The third column is also my target. Finally, I want to combine them in one datastore to feed them to my network. the code should be like this:
(This one is for a .MAT file)
folderTrain = fullfile(outputFolder,"Train");
fdsTrain = fileDatastore(folderTrain, ReadFcn=@load);
tdsPredictorsTrain = transform(fdsTrain, @(data) {data.X(1:2,:)});
preview(tdsPredictorsTrain)
tdsTargetsTrain = transform(fdsTrain, @(data) {data.Y});
preview(tdsTargetsTrain)
cdsTrain = combine(tdsPredictorsTrain,tdsTargetsTrain);
But, I can't do it with another .CSV file. The following is my code:
fdsTest = fileDatastore("C:\Users\\Desktop\Reading Material\Term 3\BDSD Minor\HAN Battery\Archive 3\25degC LFP.csv", ReadFcn=@load);
tdsPredictorsTest = transform(fdsTest, @(data) {data((5),data(4))});
1 个评论
dpb
2022-11-22
W/O the format of the csv file, there's very little (as in nothing) anybody here can do...you didn't even tell us what happened, error messages, nothing...
But, I'd be highly suspect of |
fdsTest = fileDatastore("C:\Users\\Desktop\Reading Material\Term 3\BDSD Minor\HAN Battery\Archive 3\25degC LFP.csv", ReadFcn=@load);
using load. load has a bad habit of returning different types of result variables depending upon the form of the input file. Use readmatrix or somesuch to control the input.
I'd be suspect you really need the complexity of a datastore besides -- how big is this file?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Speech Recognition 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!