MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
Asked by Nikolak on 30 Jan 2013

Hello,

I want to make a feedforward backpropagation neural network in order to solve a classification problem.

Let's say I want to import a data set from UCI Machine Learning Repository ( this one ) which is 4x306. How do I create a Target data set in order to train it?

Thanks in advance.

Answer by Greg Heath on 30 Jan 2013

Accepted answer

The target for 2-class classification has dimensions [1 N] (N=306) with values {0,1}. However, if the ratio of N1/N0 is not in the interval [0.5, 2 ], then randomly add duplicates of the smaller class until the class sizes are equal. Occasionally, it helps to add a small noise component to the duplicates.

Use PATTERNNET with a LOGSIG activation function and TRAINSCG training function. The corresponding output, y = net(x), is a consistent estimate of the posterior probability of the "1" class, given the input x, i.e., P(classind = 1 | x ). the corresponding class index can be obtained from round(y).

In general, for c-class classification, the target matrix has dimensions [ c N ]with columns of the c-dimensional unit matrix. The row index of the 1 is the class index for that column. The assigned class is obtained from classind = vec2ind(y) (the row of the largest value).

Hope this helps.

Thank you for formally accepting my answer.

Greg

Answer by Jing on 30 Jan 2013

I guess what you ask is 'preparets' function. This function prepare data for network simulation and training. Use the following command you can find the usage and an example of this function:

doc preparets

Hope it helps!

Show 1 older comment

Nikolak on 30 Jan 2013

Thank you both for your answers. I found out myself, but is there a command that creates a target matrix for your input?

For example Input is 4x150, how do I create a 3x150 target matrix(ones,zeros)? With ind2vec command?

Greg Heath on 10 Feb 2013

classind =[ 3 1 2 1 3] target = full(ind2vec(classind)) var0 = mean(var(target')) SNR = 10 rng(0) noise = sqrt(var0/SNR)*randn(3,5) fakeoutput = purelin(target+noise) predclass = vec2ind(fakeoutput)

## 0 Comments