Tall cell arrays with confusionchart()
Show older comments
Hi,
I have trained a deep learning model on a datastore. The datastore is split into three subsets; train, test and validate.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create a subset of the datastore for test, train & val purposes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
split = [10,80,10]; % [Train, val, test] as a int percentage i.e. [60,20,20]
[split_idx] = round(length(ds.Files)*(split/100));
train_idx = [1:split_idx(1)];
val_idx = [split_idx(1):split_idx(1)+split_idx(2)];
test_idx = [split_idx(1)+split_idx(2):split_idx(1)+split_idx(2)+split_idx(3)];
dstrain = subset(ds,train_idx);
dsval = subset(ds,val_idx);
dstest = subset(ds,test_idx);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
After training the model I want to generate a confusion chart. However my datastore is a tall cell array, the first cell column is data and the second column is a lable. As brace indexing isn't allowed with tall data (myarray{..,..}{..,..}) I cannot come up with a simple way to extract the lablels from the tall array. Am I missing something obvious? I will attach a sample of the data.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Train the network and calculate performance
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
net = trainNetwork(dstrain,layers,options);
YPred = classify(net,dstest,'MiniBatchSize',70);
%confusionchart(dstest(),YPred); % Trying to get the second column of
%dstest as the true labels
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Unfortunatly I received the data in a cell column format so can't just recompute to an easier format. After importing the sample data
tall(ans)
should generate a sample; 4X1 tall cell where each row is an x*2 cell array, the first column being data and the second column being the ground truth label which I would like to extract as a variable for confusionchart().
Kind regards,
Christopher
Accepted Answer
More Answers (0)
Categories
Find more on Visualization and Interpretability in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!