How to assign corresponding label to dataset
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have loaded a dataset, there are three classes as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/670393/image.png)
and I need to have the corresponding label set in order to training data with LSTM, but I don't know how to get a N*1categorical array like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/670398/image.png)
How can I do this? I really need your help.
0 Kommentare
Antworten (1)
Seth Furman
am 1 Jul. 2021
We can create categorical arrays using the categorical function.
Assuming SR, VF, and VT are cell arrays of character vectors we can call categorical with a value set. For example,
% Example data
SR = {'N','A','N','N'};
VF = {'N','N','N'};
VT = {'A','N'};
% Convert SR, VF, and VT into categorical arrays
valueset = {'N','A'};
SR = categorical(SR,valueset)
VF = categorical(VF,valueset)
VT = categorical(VT,valueset)
Assuming SR, VF, and VT are NOT cell arrays of character vectors, but can be concatenated, we can call categorical with a value set and a set of corresponding category names. For example,
% Example data
SR = {0,1,0,0};
VF = {0,0,0};
VT = {1,0};
% Convert SR, VF, and VT into categorical arrays
valueset = [0 1];
catnames = {'N','A'};
SR = categorical([SR{:}],valueset,catnames)
VF = categorical([VF{:}],valueset,catnames)
VT = categorical([VT{:}],valueset,catnames)
Siehe auch
Kategorien
Mehr zu Sequence and Numeric Feature Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!