neural network toolbox classification?
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I'm starting to learn nntool and I'd like to know if it's possible to do the following:
I have text data, like this:
- apple, red, small, 1
- apple, red, small, 1
- apple, red, big, -4
- apple, red, big, 1
- apple, yellow, small, 1
- apple, yellow, small, 1
- apple, yellow, big, -4
- apple, yellow, big, 1
- apple, green, small, 1
- apple, green, small, 1
- apple, green, big, -4
- apple, green, big, 1
and so on, with banana, cherry, etc, just the numbers in the last column are different, but all fitting a simple pattern.
I'd like to use this as training data, and then input to the network a question like:
apple, green, big, ?
and get a result for the "?".
Can that be done in matlab? If yes, could someone describe it in short? At the moment I can't even enter the data properly, importing detects just the last column, the one with numbers.
1 件のコメント
Greg Heath
2012 年 4 月 28 日
Which answer do you want ...
11. apple, green, big, -4
or
12. apple, green, big, 1
Why, and what do the numbers mean?
Greg
回答 (5 件)
Walter Roberson
2012 年 4 月 28 日
importdata() and csvread() are for numeric data only. Use textscan()
fid = fopen('YourFileName', 'rt');
datacell = textscan('%s%s%s%d', 'Delimiter', ',');
fclose(fid);
Now datacell{1} will be column 1, datacell{2} column 2, datacell{3} column 3, and datacell{4} would be the numbers.
I am assuming here that the "4." and so on are not part of the file.
0 件のコメント
Beyond
2012 年 4 月 28 日
2 件のコメント
Greg Heath
2012 年 4 月 29 日
If you answer my questions I may be able to help (even though I don't appreciate being ignored :( ).
Greg
Walter Roberson
2012 年 4 月 29 日
To check: you show us example input in which there are two numbers per line. Do both numbers exist in the file, or is the only number in each line the one at the end of the line?
If both numbers exist in the file, it gets harder to read the data because the leading number would form a column that is not delimited with comma like the other columns are.
datacell = textscan('*f%[^,],%[^,],%[^,],%d');
I do not know much about NN, but I would think it would be easier if you were to convert the strings into numbers.
Greg Heath
2012 年 4 月 30 日
Inputs to a MATLAB TBX NN are column vectors. The first three inputs are categorical and can be represented by binary numbers. For example, if the food class contains the four categories apple, banana, cherry and pepper, the corresponding categorical indices [ 1 2 3 4]are converted to the corresponding part of the 4-dimensional unit matrix obtained via the command ind2vec(index). Similarly for the color indices [1 2 3] representing red, green and yellow and size indices [1 2 3] representing small, average and big.
Consequently, a big red apple { 1 1 3 } is represented by the input column vector
[ [ 1 0 0 0]' ; [ 1 0 0 ]' ; [ 0 0 1 ]' ]
Untill I know what that last number in the OP's post is supposed to represent, I will omit it's representation.
For the ouput: There are 4*3*3 = 24 categories. Therefore the output can be represented by a column of the 24-dimensional unit matrix.
Hope this helps.
Greg
0 件のコメント
Greg Heath
2012 年 4 月 30 日
The comp.ai.neural-nets FAQ recommends bipolar binary coding { -1, 1} for input categorical variables and unipolar binary coding { 0, 1 } for output categorical variables. The corresponding recommended activation units are tanh(TANSIG) for hidden layers and SOFTMAX for the output layer.
For detailed discussions consult:
How should categories be encoded?
Why not code binary inputs as 0 and 1?
How to measure importance of inputs?
I am not that familiar with the nntool. However, it would be a good idea for you to try it first.
Hope this helps.
Greg
1 件のコメント
Greg Heath
2012 年 4 月 30 日
You still haven't explained what the number at the end of each row
represents!
Greg
参考
カテゴリ
Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!