# 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?

• If you did that what would be your loss? – Robin Nicole Dec 23 '18 at 10:44
• I don't know how to make the output three bits. I found this way(to make it one bit) easy but fall in trouble that it may considered as regression – Fahd Dec 23 '18 at 10:54
• And what about the loss you would use? – Robin Nicole Dec 23 '18 at 11:03
• I really don't know – Fahd Dec 23 '18 at 11:30
• Maybe you should start looking at that, if the loss you want to use is cross entropy it is more like classification if the loss is like mean squared error it is is closer to regression. – Robin Nicole Dec 23 '18 at 11:33