Categorical to Numeric problem
古いコメントを表示
Hi
I have a table that has numeric and categorical items in it. I have converted the catergorical items to numeric using the unique() function which works very well and I can then feed the matrix into an NN for training. The problem is when I feed new data to get results, I don't know how to make sure the converted categirical data in the new table matches ther numbers in the training data. i.e. if a categorical field in the training data is converted to the number 5, how do I make sure if that categorical data is in the new data, that it gets assigned the same number? I'm begining to think it may be a manual thing
SPG
採用された回答
その他の回答 (1 件)
Cris LaPierre
2024 年 1 月 8 日
移動済み: Cris LaPierre
2024 年 1 月 8 日
Could you provide more details about your NN? I would think you should be able to pass categorical data into your network without having to convert it to numeric first.
If not, then I'd look into creating a dictionary, where you pass in the categorical value, and it returns the numberic value.
A = categorical({'medium' 'large' 'small' 'medium' 'large' 'small'});
names = unique(A)
values = (1:length(names));
d = dictionary(names,values)
A(4)
x = d(A(4))
4 件のコメント
Stephen Gray
2024 年 1 月 8 日
Cris LaPierre
2024 年 1 月 9 日
They also accept cell arrays. What happens if you use table2cell to convert your input table to a cell array? Does it work then?
Stephen Gray
2024 年 1 月 9 日
Cris LaPierre
2024 年 1 月 11 日
"To train a network using categorical features, you must first convert the categorical features to numeric."
カテゴリ
ヘルプ センター および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!