Problem while converting tabel data to categorical (in order to use it for deep learning)
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Varun Sai Alaparthi
2023-1-9
编辑:Varun Sai Alaparthi
2023-1-9
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Custom Training Loops 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!