Problem while converting tabel data to categorical (in order to use it for deep learning)
5 views (last 30 days)
Show older comments
Hey there,
I have a 1848x4 double table of sampled data: The first three columns (named Var1 to Var3) are input data, the last one (Var4) contains the corresponding output data. There ara no NaNs.
head(tbl):
Var1 Var2 Var3 Var4
______ ____ ____ ______
180.09 0 100 297.72
162.53 0 100 266.6
144.98 0 100 233.87
127.42 0 100 194.02
109.86 0 100 156.1
92.298 0 100 129.78
74.739 0 100 107.34
57.18 0 100 86.402
Now I want to train a multilayer perceptron (MLP) network with those data, using trainNetwork in the Deep Learning Toolbox.
To do so, I followed the implementation instructions on the Matlab help center (Train deep learning neural network - MATLAB trainNetwork - MathWorks Deutschland). My Problem now is, that I'm not able to convert the labels to categorical:
If I try to run:
labelName = 'Var4';
tbl = convertvars(tbl, labelName, 'categorical');
categoricalInputNames = ["Var1" "Var2" "Var3"];
tbl = convertvars(tbl, categoricalInputNames, 'categorical');
The error:
Unable to create default category names. Specify category names using the CATEGORYNAMES input argument.
occurs.
I read about this error and it seems like it happenes, if the datas values are (occasionally) quit similar to each other. Indeed, this is the case. But now I don't know how to handel this problem. Because the further steps require a categorical tabel.
I would be very pleased, If someone could help me
0 Comments
Answers (1)
Varun Sai Alaparthi
on 9 Jan 2023
Edited: Varun Sai Alaparthi
on 9 Jan 2023
Hello Philipp,
The function cannot categorize two numbers if the difference between them is less than 5e-5. You can refer to the Categorical document for more information on this.
To solve this issue, you can first apply 'discretize' function on the ‘Var4 ‘and then convert to categorical.
tbl.Var4= discretize(tbl.Var4, min(a):1e-6:max(a))
% you van even decrease the min according to your data.
labelName = 'Var4';
tbl = convertvars(tbl, labelName, 'categorical');
Run this script and this should resolve the issue.
I hope this information helps and please reach out for any further issues.
Sincerely
Varun
0 Comments
See Also
Categories
Find more on Image Data Workflows 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!