how to classify Iris flowers I'm working on a classification problem .I want to classify Iris flowers from the famous Iris data set using MLP. I know that I the number of neurons in output layer should be the same number of classes but can I use one neuron in output layer which output is the value (0 or 1 or -1) to refer to the three types or then it is considered as regression not classification ???? thanks

trin= [4.7 3.2 1.6 0.2;
   4.8 3.1 1.6 0.2;
   5.4 3.4 1.5 0.4;
   5.2 4.1 1.5 0.1;
   5.5 4.2 1.4 0.2;
  5.7 2.6 3.5 1;
  5.5 2.4 3.8 1.1;
  5.5 2.4 3.7 1;
  5.8 2.7 3.9 1.2;
  6 2.7 5.1 1.6;
  6.7 3.3 5.7 2.1;
  7.2 3.2 6 1.8;
  6.2 2.8 4.8 1.8;
  6.1 3 4.9 1.8;
  6.4 2.8 5.6 2.1
  ];
   trout=[-1;-1;-1;-1;-1;
          0;0;0;0;0;
         1;1;1;1;1];
         inp=size(trin,2);
         out=size(trout,2);
          hidden=2;


      x=[-0.8000,-1.520,-0.9400,-3.040,3.800,2,-2,3.790,-1,0,4.600,4.400,0];
 iw = reshape(x(1:hidden*inp),hidden,inp);
 b1 = reshape(x(hidden*inp+1:hidden*inp+hidden),hidden,1);
 lw = reshape(x(hidden*inp+hidden+1:hidden*inp+hidden+hidden*out),out,hidden);
 b2 = reshape(x(hidden*inp+hidden+hidden*out+1:hidden*inp+hidden+hidden*out+out),out,1);

 y =     


tanh(tanh(trin*iw'+repmat(b1',size(trin,1),1))*lw'+repmat(b2',size(trin,1),1));
    e = gsubtract(trout,y);

is this classification or it is considered as regression . I mean should I make the out put 3 bits to be consedered as classification and how to do this if yes?
The iris dataset is meant to be used for classification. You have 3 separate classes of irises and attempting to solve it as a regression problem would be a mistake.

Think about your proposed solution, you want the output to be -1,0 or +1 (for classes a,b and c). But this implies that class a is more similar to class b than to c, and by the same principal that class c resembles class b more than a. You are adding a prior to the model that was not there before, and you should not do that (unless you are an iris specialist).

you need to take your class output labels and convert them to a one-hot-encoding representation:
class a = [1,0,0]
class b = [0,1,0]
class c = [0,0,1]

Then use categorical cross entropy for your loss function.