neural network toolbox classification?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Greg Heath
le 28 Avr 2012
Which answer do you want ...
11. apple, green, big, -4
or
12. apple, green, big, 1
Why, and what do the numbers mean?
Greg
Réponses (5)
Walter Roberson
le 28 Avr 2012
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 commentaires
Beyond
le 28 Avr 2012
2 commentaires
Greg Heath
le 29 Avr 2012
If you answer my questions I may be able to help (even though I don't appreciate being ignored :( ).
Greg
Walter Roberson
le 29 Avr 2012
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
le 30 Avr 2012
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 commentaires
Greg Heath
le 30 Avr 2012
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 commentaire
Greg Heath
le 30 Avr 2012
You still haven't explained what the number at the end of each row
represents!
Greg
Voir également
Catégories
En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!