views:

231

answers:

1

I have a training set that has input and outupts in this way:

Input:
0.832 64.643
0.818 78.843
1.776 45.049
0.597 88.302
1.412 63.458
1.468 49.535
1.985 33.387
2.073 30.279
1.431 55.231
1.116 68.521
1.617 44.362
2.159 66.512

Output:
0 0 1
0 0 1
0 1 0
0 0 1
0 0 1
1 0 0
0 0 1
1 0 0
1 0 0
0 0 1
0 0 1
0 1 0
1 0 0
1 0 0
0 1 0
0 1 0

I need to implement one linear layer neural network that can represent the data set best in matlab. what should be the algorithm for it to do in matlab?

The target output is "1 for a particular class that the corresponding input belongs to and "0 for the remaining 2 outputs.

+3  A: 

Consider this example of training a feed-forward ANN of one hidden layer (with 3 nodes). Since your data seems to have more output points than input, I'm using a demo dataset, but the idea is the same:

%# load sample data
laod simpleclass_dataset
input = simpleclassInputs;          %# 2x1000, 2-dimensional points
output = simpleclassTargets;        %# 4x1000, 4 classes

%# split data into training/testing sets
trainInd = 1:500;
testInd = 501:1000;

%# create ANN and initialize network weights
net = newpr(input, output, 3);
net = init(net);
net.trainParam.epochs = 25;        %# max number of iterations

%# learn net weights from training data
net = train(net, input(:,trainInd), output(:,trainInd));

%# predict output of net on testing data
pred = sim(net, input(:,testInd));

%# classification confusion matrix
[err,cm] = confusion(output(:,testInd), pred);

The output is:

err =
     0.075075
cm =
    81     0     0     0
     0    82     0     0
     9     0    52    16
     0     0     0    93

Obviously you will need access to the Neural Network Toolbox.

Amro
Thanks for answering the question...It might help me alot....and the input and outputs are equal. I just copied some inputs and outputs to show you the format of my input n outputs.
Shilpa
the weights of the neural network is determined by "net"???
Shilpa
`net` is an object which stores all the network parameters. If you want to recover the actual weights, look into `net.IW net.LW net.b` for input layer weights, hidden layers weights, and biases respectively. To learn more about the structure of this object, please refer to the documentation of the toolbox..
Amro
how did you split the data "trainInd = 1:500; testInd = 501:1000; "I mean- 1:500 - u took it as per your choice or some logic behind it?
Shilpa
that was just a random split (half for training, half for testing); the idea is that if you want to validate the model and get an accurate estimate of the error, you will need some kind of random resamling. For more sophisticated methods, check out CVPARTITION or CROSSVALIND functions. In fact, I believe that the NN-toolbox has some capabilities for doing just that, see `help(net.divideFcn)`
Amro
I have downloaded the matlab software but I dont know how to access the neural network? I have 2 files - 1 for input and other for output and I hv imported the 2 files in matlab and trying to run it, but it is not prducing anything? Load_simpleclass_dataset- do i need this one? I imported the files already- input.data and output.data - these are the names of the files
Shilpa
I have the simulink toolbox...would it work for it? I dont have neural toobox
Shilpa
Each toolbox is considered a separate product. Type `ver` in the MATLAB command prompt to see what toolboxes are available to you. In case you don't have the Neural Network Toolbox, there are many other free alternative like Netlab, but you would have to read their documentation: http://www1.aston.ac.uk/eas/research/groups/ncrg/resources/netlab/
Amro
ya...I have simulink toolbox...I wrote "ver " in the coomand line and it shows that I have simulink in matlab
Shilpa
simulink,Bioinformatics Toolbox ,Control System Toolbox , curve fitting Toolbox ,Data Acquisition ,Image Processing , Instrument Control toolbox,SimMechanics, Simscape, Stateflow, Statistics Toolbox
Shilpa
I need to use only matlab I guess...I dont think, I can use those toolboxes...How to implement 1 layer neural network if i dont use any toolbox and do it by simple matlab.I have 2 files- input.data and output.data and both have 2 columns with equal entries.
Shilpa
And how can I access the data from my 2 files that I have....I imported the two files but dont know how to make it possible?And You are only one who has responded this question. Thanks. Much appreciated.
Shilpa
Implementing a neural network is not a simple task. I suggest you pick up a book and familiarize yourself first (plenty of books on the subject). You can then start by looking at someone else's implementation; search questions here on SO, one comes to mind which implements a simple Perceptron in C: http://stackoverflow.com/questions/1697243/help-with-perceptron/1714030#1714030
Amro
i can't find it by myself.I am confused with 2 files that i have. The input.data and output.data. I imported these 2 files but how i can use these files in my program.
Shilpa
load simpleclass_dataset....... input = simpleclassInputs; output = simpleclassTargets;...... I have two files....wht shud I do with that 2 files here??you are using load simpleclass-dataset ....but I dont have that class as such??
Shilpa